Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To read a Serial Port data in to a Log file?

Status
Not open for further replies.

JohnLynn

Technical User
Feb 2, 2001
38
US
I have a Caller-ID box that puts out serial information with out flow control.

I would like to log this information to a file.

I have not seen a script solution that will allow me to read a standart /dev/ttySx on RedHat Linux.

Any ideas?

Thanks in advance.
John

 
If you don't like perl, tcl has a very nice
interface to channels and serial ports and has a very
cool event loop which is good for diagnostics,traces,
garbage collection and other event happy stuff ;)

proc poll {chan} {
if {![eof $chan]} {
puts "No eof detected on serial channel $chan at [exec date]"
after 15000 [list poll $chan]
} else {
puts "Detected eof , serial connection closed."
return 1;
}
}

proc loggit {filename chan} {
set myopen [open $filename "a+"]
while {[gets $chan line] > 0} {
puts $myopen $line
}
catch {close $myopen}
return
}


if {![catch {set myhandle [open /dev/ttyS? "r"]}]} {
fconfigure $myhandle -mode ?baud,parity,data,stop?
fileevent $myhandle readable [list loggit logfile $myhandle]
after 15000 [poll $myhandle]
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top