ProSoft Technology MVI69E-LDM User Manual
Page 49

MVI69E-LDM ♦ "C" Programmable
Contents
Linux Application Development Module
Developer's Manual
ProSoft Technology, Inc.
Page 49 of 130
August 21, 2014
4.2.2 Serial Sample
To run the Serial sample:
1 Establish a command window using Telnet or similar terminal software on the PC
through the Ethernet E1 port or Serial P1 port.
2 Login:
user:
root
password:
password
To execute the sample:
1 Navigate to the default home directory
/psft/sample
.
2 Type the command
./Serial_Sample ttyS1 test string
in order to run the program with
ttyS1 as the output, and "test string" sent to that port.
While reviewing the source code for
Serial_Sample
, you'll see that the main program:
registers
sigquit_handler
for four signals.
checks command line and print usage message if required.
opens the backplane using
open_backplane()
. See the detailed description in
backplane_sample
.
reads the serial configuration jumpers and ensures that both serial ports are configured
as RS232.
opens the serial port using function
open_serial_port()
. Examine this function:
o
opens the serial device by calling
open()
.
o
reads current serial port attributes using
tcgetaddr()
.
o
configures serial port attributes. The routine uses
cfsetispeed()
to set the baud rate.
It then uses
tcsetattr()
to set the remaining attributes.
initializes the LEDs on the front panel.
enters a for loop which transmits a test string one character at a time by calling
write()
and sleeping for 500 msec using
usleep()
.
closes the serial drive connection using
close()
.