software read serial port and write log

Forum regarding Linux Software and Home Automation Domotica.
Post Reply
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

software read serial port and write log

Post 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?
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

software read serial port and write log

Post by Kroonen »

Well some documentation to start with

http://www.mm.helsinki.fi/~mpastell/serial.pdf
Kroonen
Member
Member
Posts: 302
Joined: Mon Oct 01, 2007 6:38 pm
Location: Netherlands

software read serial port and write log

Post 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
ddgiel
Starting Member
Starting Member
Posts: 25
Joined: Fri Dec 05, 2008 4:20 pm
Location: Belgium

software read serial port and write log

Post by ddgiel »

In Perl, open the file /dev/ttyUSB0.
Create a loop of reading every line, after each line process it.
User avatar
Snelvuur
Forum Moderator
Forum Moderator
Posts: 3156
Joined: Fri Apr 06, 2007 11:01 pm
Location: Netherlands
Contact:

software read serial port and write log

Post 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)
t006
Starting Member
Starting Member
Posts: 26
Joined: Wed Oct 08, 2008 8:09 pm
Location: Netherlands

Re: software read serial port and write log

Post 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>){     
    
}
Post Reply

Return to “Linux Forum”