Version 3 (modified by 15 years ago) ( diff ) | ,
---|
Serial Ports
Using Serial Ports for Linux Shell
By default, the Cardinal 825 ships with the Linux console disabled. To enable it, start the indicator and press 3. Setup Menu. Next, press 4. Update Software Menu and then 3. Settings. If you see console=null, remove that line. Save the settings and reboot your indicator. You will now see Linux output from COM1.
Generic Serial Port Use
The “COM1” and “COM2” serial ports are routed through the main board to the MCF5329 processor on the operator interface board. These ports are controlled by the appropriate uCLinux device driver for the built in Coldfire serial ports. These ports may be accessed as:
/dev/ttyS0 = COM1 /dev/ttyS1 = COM2
For example you may test from the serial terminal by typing:
# echo “Hello” > /dev/ttyS1
This will send the message “Hello” out the COM2 serial port. The 825 COM3 port is connected to the main board MCF5213 processor. If the 825 is configured for OIML operation this port is dedicated to sending OIML format verification weight and may not be used by applications. If OIML is not enabled applications may access the COM3 port by means of the mnbd-comm device driver. For example:
# echo “H313233” > /dev/mnbd
This will output “123” to the COM3 port. Note 31 hexadecimal for the ASCII character “1”, 32 is hexadecimal for the ASCII character “2”, etc. As of kernel 2008-11-20 an additional device file /dev/com3 is provided to simplify COM3 application communications. This additional device file is also controlled by the mnbd-comm device driver.
# echo “123” > /dev/com3
This will output “123” to the COM3 port.
To perform a similar operations within a C program you may use code similar to:
This will write to COM2. Note fprintf also allows format specifiers such as %d to be used:
int nID = 240; fprintf(pFile, "ID: %d\r\n", nID);
This would output "ID: 240".
You may want a program that reads the serial port and responds:
This sample displays updating weight on the LCD display and will exit when the Shift-ESC key on the keypad is pressed. If CTRL-F is received on the COM2 port this application will send "ACK received<CR><LF>" out the serial port in response. If CTRL-U is received on the COM2 port this application will send "NACK received<CR><LF>" out the serial port in response. If CTRL-B is received the application will start buffering subsequent received characters. When CTRL-C is received the application will respond back with the buffered characters and stop buffering.