0

I have a telephone system that is connected to my old Ubuntu machine and is receiving SMDR data from it. Connected to dev/lp0 is a dot matrix printer, phone system connected to /dev/ttyS0

Currently I am using the command cat /dev/ttyS0 > /dev/lp0. This works somewhat but the smdr print has a cr and lf commands for the printer already. Cat send to make the printer feed an extra line. Is there a way to constantly echo ttyS0 to lp0 or something else I can do? Thanks

0

You need to remove postprocessing from /dev/lp0. Try the following:

(
stty -F /dev/lp0 -opost
cat /dev/ttyS0
) > /dev/lp0

Enclosing the two commands in a subshell and redirecting its output to /dev/lp0 prevents the stty settings being reset to default when no process has /dev/lp0 open anymore (inbetween the stty and the cat).

Perhaps you also need to change /dev/ttyS0 settings, e.g. remove any input processing: stty -F /dev/ttyS0 -icanon -echo min 8 time 1 (the min 8 time 1 means that reads will return as soon as at least one byte is read and no further input is available after 1/10th of a second, or if more input becomes available reads will return after at most 8 bytes read).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.