Sending Ascii characters to serial device Linux


Thread Starter


I have a Magellan scanner/scale for a Point of Sale checkout that is on a serial port. I am receiving appropriate data on the serial port, ttyS0, for items scanned, however, I need to be able to send the ASCII character 13 to the scale for it to recognize that I am looking for the weight on the platform, rather than wanting it to look for an item to scan. I am fairly new to the concept of writing/communicating with serial devices, so am not sure if this is something I can do at the terminal level of Linux, or if it is something I need to be embedding in a perl, c+ script or what.

Any input on this would be a great help. We have sucessfully done this with VB on a Windows 2K system, but would like to port this application to Linux/OpenSource.

Thanks in advance,


Curt Wuollet

I would do it the same way that you are receiving data so you can synchronize. If you have a program opening the port and reading from it, you would simply do a fputc or write to the stream or file descriptor depending on whether you are in raw or cooked IO mode.

I have some boilerplate Linux serial code I could post if it would be useful (and I can find it). Any UNIX programming text should cover this as well.

Without programming, you can use a script or use a terminal. A serial port is still just a file under *nix so almost anything can be made to work. You can even do it from the command line with something like echo '\015' > /dev/ttyS0. (octal)