COM PORT IN LINUX

S

Thread Starter

SARAVANAN

Need a simple linux command to control simple application in external MCU like LED On/Off. Any few lines?
 
Here's a couple of links for you:

Here's the official Howto documentation for serial ports with Linux:
http://tldp.org/HOWTO/Serial-HOWTO.html#toc12

If you want to write a simple program, then use Python with Pyserial:
http://pyserial.sourceforge.net/

If you just want to send some bytes out of a serial port, then just remember that with unix (Linux) everything is a file, including the serial ports. You can use a bash script to set the serial port parameters using setserial, and then write characters to the serial port file.

If you just want to write a simple Python program to do a bit more (e.g. you need to write binary messages, rather than just ASCII characters), then you can get a simple Python program running with just a few lines of code. The Pyserial documentation is quite good, and has examples. Pyserial should be in your distro's repo and Python is installed by default on most popular Linux distros.

If you have any more questions I will be happy to help.
 
C

curt wuollet

You can do this with everything from a shell script to any of the dozens of languages available. If you want something close, it would help to mention what you have to send and receive. I can post example C code, but depending on what you have to do, it might not be simple. You can use a terminal emulator like Minicom to experiment with and send strings to the MCU then write a script or program to do what you need. But without what you need to send, it's pretty hard to point you in the right direction. It might be as simple as:

stty -F /dev/ttyS0 sane
echo "MCU control string" > /dev/ttyS0

or 5 pages of C code if you have to do weird port settings and handshake and do a CRC or LRC.

Regards
cww
 
Here are some simple open-source zips I just updated a couple of days ago:
http://www.turbocontrol.com/easyfpgui.htm

They work in i386-linux and arm-linux as well as windows.

The DbgTerm program is similar to HyperTerminal but is easy to modify since it has very little code. I hope to update that program very soon to add TCP/IP capability.
 
Top