Serial Programming: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Tools: minicom and cutecom) |
||
Line 34: | Line 34: | ||
=== [http://alioth.debian.org/projects/minicom/ Minicom] === |
=== [http://alioth.debian.org/projects/minicom/ Minicom] === |
||
[http://alioth.debian.org/projects/minicom/ Minicom] ([http://en.wikipedia.org/wiki/Minicom wikipedia]) is a text-based modem control and terminal emulation program for Linux. |
'''[http://alioth.debian.org/projects/minicom/ Minicom]''' ([http://en.wikipedia.org/wiki/Minicom wikipedia]) is a text-based modem control and terminal emulation program for Linux. |
||
It can be used to debug / test serial connections, but unfortunately it is only ascii based and does not allow to send / receive easily data in hexadecimal format (except via sending / receiving files). |
It can be used to debug / test serial connections, but unfortunately it is only ascii based and does not allow to send / receive easily data in hexadecimal format (except via sending / receiving files). |
||
Minicom is in the repositories: |
|||
<source lang=bash> |
|||
sudo apt-get install minicom |
|||
</source> |
|||
=== [http://cutecom.sourceforge.net/ Cutecom] === |
=== [http://cutecom.sourceforge.net/ Cutecom] === |
||
[http://cutecom.sourceforge.net/ Cutecom] is a handy and easy graphic tool to test/debug embedded devices controlled via serial link. This tool allows sending / receiving data in hexadecimal format. |
[http://cutecom.sourceforge.net/ Cutecom] is a handy and easy graphic tool to test/debug embedded devices controlled via serial link. This tool allows sending / receiving data in hexadecimal format. |
||
Cutecom is in the repositories: |
|||
<source lang=bash> |
|||
sudo apt-get install cutecom |
|||
</source> |
Revision as of 22:09, 1 February 2012
References
- Serial Programming HOWTO
- Serial Programming Guide for POSIX Operating System
- Serial Port Programming in Windows and Linux
How-To
Flush Serial Buffers
Use constant TCSAFLUSH
for function tcsetattr
(see [1] and [2]):
Constant | Description |
---|---|
TCSANOW | Make changes now without waiting for data to complete |
TCSADRAIN | Wait until everything has been transmitted |
TCSAFLUSH | Flush input and output buffers and make the change |
This can be done even on a serial port that is already configured:
struct termios options;
tcgetattr(fd, &options); // Get current configuration of this port
cfsetispeed(&options, B115200); // Configure some port options (e.g. baud rate...)
...
tcsetattr(fd, TCSANOW, &options); // Apply the new settings immediately
... // Read / Write to the port...
tcsetattr(fd, TCSAFLUSH, &options); // Flush IO buffer
Tools
Minicom
Minicom (wikipedia) is a text-based modem control and terminal emulation program for Linux.
It can be used to debug / test serial connections, but unfortunately it is only ascii based and does not allow to send / receive easily data in hexadecimal format (except via sending / receiving files).
Minicom is in the repositories:
sudo apt-get install minicom
Cutecom
Cutecom is a handy and easy graphic tool to test/debug embedded devices controlled via serial link. This tool allows sending / receiving data in hexadecimal format.
Cutecom is in the repositories:
sudo apt-get install cutecom