software read serial port and write log

Forum regarding Linux Software and Home Automation Domotica.

software read serial port and write log

Postby Kroonen » Wed Apr 15, 2009 8:20 pm

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?
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

software read serial port and write log

Postby Kroonen » Wed Apr 15, 2009 9:03 pm

Well some documentation to start with

http://www.mm.helsinki.fi/~mpastell/serial.pdf
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

software read serial port and write log

Postby Kroonen » Wed Apr 15, 2009 9:55 pm

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
Kroonen
Member
Member
 
Posts: 302
Joined: October 2007
Location: Netherlands

software read serial port and write log

Postby ddgiel » Thu Apr 16, 2009 8:48 am

In Perl, open the file /dev/ttyUSB0.
Create a loop of reading every line, after each line process it.
ddgiel
Starting Member
Starting Member
 
Posts: 25
Joined: December 2008
Location: Belgium

software read serial port and write log

Postby Snelvuur » Thu Apr 16, 2009 11:13 am

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)
User avatar
Snelvuur
Forum Moderator
Forum Moderator
 
Posts: 3156
Joined: April 2007
Location: Netherlands

Re: software read serial port and write log

Postby t006 » Sun May 02, 2010 3:56 pm

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>){     
   
}
t006
Starting Member
Starting Member
 
Posts: 26
Joined: October 2008
Location: Netherlands


Return to Linux Forum

Who is online

Users browsing this forum: No registered users and 1 guest

cron