ProSoft Technology MVI56E-LDM User Manual
Page 55

ControlLogix Platform ♦ "C" Programmable
Understanding the MVI56-LDM API
Linux Application Development Module
Developer's Manual
ProSoft Technology, Inc.
Page 49 of 264
March 12, 2014
4.12 Serial Sample
To run the Serial sample:
1 Open a command window using telnet or a similar terminal software on the
PC through a serial (P1) or Ethernet port.
2 Login as user: root, password: password.
The second serial port (P2) will be used for the communication sample.
To execute the sample:
1 From the default home directory
/psft
, type the command
./Serial_Sample&
.
The program runs as a background task.
While looking at the sample source, you'll see that the following occurs:
register
sigquit_handler
for four signals
check command line and print usage message if required
open the backplane using
open_backplane()
Read the serial configuration jumpers and make sure that the second serial
port is configured for RS232.
Open the serial port using the
open_serial_port()
function.
Opens the serial device by calling
open()
Reads current serial port attributes using
tcgetaddr()
Configures serial port attributes.
cfsetispeed()
and
cfsetispeed()
set the
baud rate.
tcsetattr()
is then used to set the remaining attributes.
Initialize LEDs on the front panel
Changes the front panel display to "Run"
Enters a for loop which transmits a test string one character at a time by
calling
write()
and then sleeping for 500 msec using
OCXcip_Sleep()
Closes the serial driver connection using
close()
.