Page 1 of 1
software read serial port and write log
Posted: Wed Apr 15, 2009 8:20 pm
by Kroonen
Hi,
I'm using nodo that bridge IR->RF (kaku) and works with eventghost, but this is in windows.
I'm looking for some linux software , or someone who writes some, that reads the serial/usb port /dev/ttyUSB, that writes to and log file example /var/log/nodo.log the events, and you can set some actions (scripts) on those events. So nog graphical interface is required
any ideas/help?
software read serial port and write log
Posted: Wed Apr 15, 2009 9:03 pm
by Kroonen
software read serial port and write log
Posted: Wed Apr 15, 2009 9:55 pm
by Kroonen
Well logging works
wodan:~# nohup cat /dev/ttyUSB0 > nodo.txt
nohup: ignoring input and redirecting stderr to stdout
^X^C
wodan:~# cat nodo.txt
C3=0
AAB50D2=0
AB50D2=0
AAB50D2=0
AB50D2=0
But how do I get an action to it, for example is C3=0 than launch script ./lamp3on
software read serial port and write log
Posted: Thu Apr 16, 2009 8:48 am
by ddgiel
In Perl, open the file /dev/ttyUSB0.
Create a loop of reading every line, after each line process it.
software read serial port and write log
Posted: Thu Apr 16, 2009 11:13 am
by Snelvuur
kroon: take a look at the perl script for the ti0203 (comes with mister house i believe) it has also a read on the serial and has a loop and such, more example are out there.
// Erik (binkey.nl)
Re: software read serial port and write log
Posted: Sun May 02, 2010 3:56 pm
by t006
I use perl also for this.
A short code sample below...
Code: Select all
use Device::SerialPort;
$ob = Device::SerialPort->new ($PORT) || die "Can't Open $PORT: $!";
$ob->baudrate(115200) || die "failed setting baudrate";
$ob->parity("none") || die "failed setting parity";
$ob->databits(8) || die "failed setting databits";
$ob->handshake("none") || die "failed setting handshake";
$ob->write_settings || die "no settings";
open(DEV, "<$PORT")
|| die "Cannot open $PORT: $_";
while($_ = <DEV>){
}