[time-nuts] Serial Port Logging Script?
Didier Juges
didier at cox.net
Tue Jan 23 01:58:13 UTC 2007
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.
>
>
>
>
>
>
More information about the Time-nuts_lists.febo.com
mailing list