Overview 06/2005
Danaher
Motion
6 Rev
E
M-SS-005-03l
1.8.1.2. O
PEN
S
ERIAL
P
ORT
Configurate the serial port with
OPEN
. Set the following port properties:
BaudRate
- baud rate of the device set to a specified value.
Parity
– enable/disable parity detection. When enabled, parity is odd or even.
DataBits
- number of data bits.
StopBit
- number of stop bits.
Xonoff
– sets raw mode or ^S/^Q flow control protocol mode (optional parameter
disabled by default).
For example:
OPEN COM2 BUADRATE=9600 PARITY=0 DATABITS=8 STOPBIT=1 AS #1
Opens COM2 at 9600 bps baud-rate, No parity, 8-bit data, 1 stop bit.
OPEN
assigns a device handle to the communication port. Any further
references to the communication port uses the device handle number. The
device handle range is 1…255. To change the communication parameters,
close the serial port and reopen it using the new parameters. For more
information, see
PRINT #
and
INPUT$
.
1.8.2. TCP/IP
Communication
Use TCP/IP communication with other computers and intelligent I/O devices
over the Ethernet network. MC-BASIC uses TCP/IP API (sockets).
TCP/IP provides multi-thread communications. The same physical link
(Ethernet) is shared between several applications. This way, the MC can
connect to BASIC Moves and one or more intelligent I/O devices.
The MC supports both client and server roles for TCP/IP communications.
The TCP/IP client connects to a remote system, which waits for a connection
while the TCP/IP server accepts a connection from a remote system.
Usually, the MC serves as client while interfacing to an intelligent I/O
connected to the LAN, and as a server when working toward remote host like
a software PLC. The MC uses Realtek RTL8019AS Ethernet NIC at a bit rate
of 10 M bps.
1.8.2.1. S
ETUP
TCP communication starts by opening a socket either to connect to a remote
computer (remote host) or accept a connection from a remote host. Use
CONNECT
or
ACCEPT
, depending on the MC functionality (client or server).
OPENSOCKET
creates a TCP socket and assigns the socket descriptor to
the specified device handle. The socket is created with
OPTIONS
NO_DELAY (send data immediately= 1). Otherwise, the data is buffered in
the protocol stack until the buffer is full or a time-out is reached. This
improves responsiveness when small amounts of data are sent. This option
is recommended for interactive applications with relatively small data
transfer. Otherwise,
OPTIONS
= 0.
OPENSOCKET OPTIONS=1 AS #1
OPENSOCKET
assigns a device handle to the communication port (as
OPEN
). Any further reference to the communication port uses the device
handle number. The device handle range is 1…255.