[time-nuts] Serial Port Logging Script?

Didier Juges didier at cox.net
Tue Jan 23 02:27:43 UTC 2007


I have posted the source for the rpm program below (rpm.c). You might 
want to use it as a basis to do the formatting and time stamping of the 
data received by the serial port. That's what this program was written 
for, even though it was intended for data in a specific format for an 
application where I work, so you will have to clean it a little bit (or 
a big bit...)

http://www.ko4bb.com/linux/Serial

Didier KO4BB

PS: disclaimer: for those who may not have noticed, I am not a software 
professional :-)

PPS: the original shell script below sets the serial port in raw mode 
because the data it is intended to process contains control characters, 
which would confuse the shell (I think). You may be able to do a cleaner 
implementation if you only use printable ASCII characters.


Didier Juges wrote:
> Here is a shell script that sets a serial port, reads data from the 
> serial port and pipes it to another program (rpm)
>
> #!/bin/sh
>
> # open ttyS1, set to 19200 and raw mode (so as not to choke on checksum)
> stty 19200 raw </dev/ttyS1
>
> # Print what comes from ttyS1, filter through rpm
> cat </dev/ttyS1 |./rpm -n $1 $2 $3 $4
>
> You can change the last line as follows:
>
> cat </dev/ttyS1 > dada.txt
>
> to send the data to a file instead.
>
> Change serial port or setting as you see fit.
>
> Didier KO4BB
>
>
> Hal Murray wrote:
>   
>>> Does anyone have a simple Perl (or C) script to write data from a
>>> serial port to a file? Preferably something with no dependencies, but
>>> I don't mind having to install a couple Perl modules if need be.
>>>     
>>>       
>> Most terminal programs have a log-to-file option.
>>
>>
>>   
>>     
>>> I tried the logserial program that I found in the FreeBSD ports tree,
>>> but it keeps putting extra returns in between each row of data. 
>>>     
>>>       
>> Is that a CR vs CR/LF mixup?  If so, record it however you can and clean out 
>> the LFs later.  I used to have scripts that converted from one mode to 
>> another.  I think one used sed and the other used awk.
>>
>> If it really is an extra blank line, that should be reasonably easy to filter 
>> out.
>>
>>
>>
>>
>>
>>   
>>     
>
> _______________________________________________
> time-nuts mailing list
> time-nuts at febo.com
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
>
>   




More information about the Time-nuts_lists.febo.com mailing list