2. Getting Started Getting Started 2.1. Debugging Debug The Best Way To Debug Your Code Is To Set Up Another Linux Box, And Connect TWO
Computers Via a Null-Modem Cable. Use Miniterm (Available from The LDP Programmers
Guide (ftp://sunsite.unc.edu/pub/linux/docs/ldp/programmers-guide/lpg-0.4.tar.gz
In The Examples Directory to Transmit Characters to Your Linux Box. Miniterm CAN
Be Compiled Very Easily and Will Transmit All Keyboard Input Raw over the Serial
Port. Only The Define Statement #define modemdevice "/ dev / ttys0" HAS to be checked.
Set it to ttys0 for Com1, TTYS1 for Com2, etc .. it is essential for testing, That
All Characters Are Transmitted Raw (WITHOUT OUTPUT Processing) Over the line. To
Test Your Connection, Start Miniterm on Both Computers and Just Type Away. The
Characters Input On One Computer Should Appear on The Other Computer and Vice Versa.
The INPUT WILL NOT BE Echoed to the attach screen.
The best way to debug code is to establish a Linux host (Linux box), a serial port with a non-modulated demodulator
NULL-MODEM connection two machines. You can also use Minicom (you can get from the LDP program guide:
ftp://sunsite.unc.edu/pub/linux/docs/ldp/...lpg-0.4.tar.gz
Examples directory) To transfer characters to your Linux host. Miniterm is easy to compile and directly put the keyboard
Input does not process (RAW mode) to the serial port. Just apply to definition #define modemdody "/ dev / ttys0"
Change. COM1 is set to TTYS0, and COM2 is TTYS1, which pushes ... test is required, all
The characters are transmitted directly through the cable, and any output is not performed. In order to test your connection, open on your two machines
Enter minicom, then enter some characters free. The characters entered from a computer should be displayed on another device
On, vice versa. The input character does not return (echo) on the local screen.
To make a null-modem cable you have to cross the txd (transmit) and rxd (receive)
For A Description of a Cable See SECT. 7 of The Serial-Howto.
When a serial connecting line (Null-modem cable) of the non-modulated demodulator, you need to transfer one end (TXD)
Connect with the receiving end (RXD) of the other end, the receiving end of one end is connected to the transfer end of the other end, see the Serial-HowTo Section 7 for details.
It is also possible to perform this testing with only one computer, if you have
Two unused serial ports. You can the run two miniterms off..
IF you free a serial port by disconnecting the mouse, Remember to redirect / dev / mouse
If IT EXISTS. if you use a Multiport Serial Card, Be Sure To Configure It Correctly.
I Had Mine Configured Wrong and Everything Worked Fine As Long As I Was Testing
ONLY ON My Computer .hen i connection to another computer, The port started loosing
.
If your computer has two idle serial ports, you can do these tests as long as you use a machine. You
You can run a miniterm on both virtual console, which is used to send and receive results, respectively. If you use the serial port
Mouse, remember to reset the / dev / mouse before the test. If you use multi-port serial card (MultiPort Serial
Card), be sure to configure this device, and my computer has such problems because of the configuration error:
When I test on my own machine, everything is normal, and when connecting to other computers, the port begins to lose data.
Note that running two serial applications on a machine is not fully asynchronous.
2.2. Port Settings Port Setting The Devices / Dev / Ttys * Are Intended to Hook Up Terminals To Your Linux Box, And
Are Configured for this USE After Startup. this Has To Be Kept in Mind When Programming
Communication with a raw device. E.G. The ports area configured to echo character
Sent from The Device Back to It, Which Normally Has To Be Changed for Data Transmission.
Equipment / dev / ttys * will be used as terminal devices connected to your Linux machine, and it is already
Configured. This is necessary to keep in mind when you write the serial communication program of the RAW device. For example, this serial port
It is set to return (echo) all the characters sent from this device, usually change this work when doing data transmission.
mode.
All Parameters Can Be Easily Configured from Withnin a Program. The Configuration
Is Stored in A Structure Struct Termios, Which is defined in
Code
#define nccs 19struct termios {
Tcflag_t c_iflag; / * Input mode flags * /
Tcflag_t c_oflag; / * Output Mode Flags * /
Tcflag_t c_cflag; / * Control Mode Flags * /
TCFLAG_T C_LFLAG; / * local mode flags * /
CC_T C_LINE; / * LINE Discipline * /
CC_T C_CC [NCCS]; / * Control Characters * /
}
All parameters can be easily configured in the program. Configuration Save in Structural Struct Termios, this structure is defined in
Code
#define nccs 19
Struct termios {
Tcflag_t c_iflag; / * Input mode flag * /
Tcflag_t c_oflag; / * Output mode logo * /
Tcflag_t c_cflag; / * Control Mode Sign * /
Tcflag_t c_lflag; / * Local mode logo * /
CC_T C_LINE; / * Row Control LINE Discipline * /
CC_T C_CC [NCCS]; / * Control Character Control Characters * /
}
This file also includes all flag definitions. The Input Mode Flags in C_IFlag Handle
All Input Processing, Which Means That The Characters Sent from The Device Can Be
Processed Before The is is read with read. Similarly C_OFLAG HANDLES The OUTPUT Processing.
C_cflag contains the settings for the port, as the baudrate, Bits Per Character,
Stop bits, etc .. The local mode flags stiled in c_lflag determine if charactermine
Echoed, Signals Are Sent to your program, etc .. finally the array c_cc defines the
Control Characters for End of File, Stop, etc .. Default Values for the Control
Characters Are Defined in
.
Which is not used in Posix Compliant Systems.
This file also includes all definitions of all flags (Flag). Input mode flag in c_iflag, perform all input
Treatment, that is, the characters from other devices, before being read by the read function, first according to the flag
. Similarly, C_OFLAG defines all output processing. C_cflag includes settings for ports, such as baud rates, stop symbols, and the like. c_lflag includes, determine whether the character is exposed, whether the signal is sent to your program, etc.
All local work methods. C_cc defines all control symbols, such as file end characters and stop characters, etc.
Some default values of these parameters are defined in
specific description. The TERMIO structure also includes a C_LINE parameter (row control) that cannot be used in the POSIX system.