Tech support

Linux: Howto forward output to serial port?

Started by etno 3 posts last post 6 years ago

#1

Hi,

under DOS and Windows i can forward a output to a serial port. For example if i type "dir > com1" i can give the output, in this case it is a info about my folders and files in the current directory, to a device wich is connected to com1.
Is there a way howto do this under linux?

Thanks in advance,
Eric
Religion ist Opium fürs Volk!

#2

All devices on Unix are mapped to a device file, the serial ports would be /dev/ttyS0 /dev/ttyS1 ... .
First have a look at the permissions on that file, lets assume you are using /dev/ttyS1.
ls -l /dev/ttyS1
You will want read.write access, if this is a shared system then you should consider the security consequences of opening it up for everyone.
chmod o+rw /dev/ttyS1
A very simple crude method to write to the file, would use the simple echo command.
echo -ne '\033[2J' > /dev/ttyS1
and to read
cat -v < /dev/ttyS1
You can have cat running in one terminal, and echo in a 2nd.
If everything is gibberish, then baud rate, bit settings might need setting before you start sending. stty will do that. !! NOTE stty will use stdin as default file descriptor to affect.
Equivalent commands.
stty 19200 < /dev/ttyS1
stty 19200 -F /dev/ttyS1
This might be enough for you to script something and log ? Not sure what you are trying to achieve.
sometimes the world is better without sight...
Because you can see the world how it really is...
Dark

#3

Thank you, i'll try it. I use a virtual machine running android X86. I have the possibility to use the Linux system Android X86 is based on. I would like to forward some outputs to my Virtual BNS because i can't add any screenreader to the cernel..
Religion ist Opium fürs Volk!