Overview 06/2005
Danaher
Motion
1.8.3.3. S
END
D
ATA
B
LOCK
PRINTTOBUFF #
and
PRINTUSINGTOBUFF # a
llows buffering of data
before actually being sent. This eliminates inter-character delays.
printtobuff #handle,chr$(0); chr$(message_length);
chr$(0);send=false
printtobuff #handle,chr$(request[ii]);send=false
printtobuff #handle,chr$(request[ii]);send=true
1.8.3.4. S
END
/R
ECEIVE
NULL C
HARACTER
When using a specific protocol over Serial or TCP/IP ModBus RTU or
ModBus TCP), the NULL character is part of the message. The message
block cannot be saved in a STRING type variable since the NULL character
terminates the string.
To send a NULL character in a message, send the data as single bytes
instead of a string type message:
COMMON SHARED X[10] AS LONG
X[1]=0x10
X[2]=0
X[3]=0x10
PRINT #1, CHR$(X[1]);CHR$(X[2]);CHR$(X[3]);
The output is the following stream of bytes:
0x10, 0x0, 0x10
When the received data contains a NULL character, read the data from the
input buffer as single bytes instead of reading it into a string type variable.
Convert the incoming data to a numeric value to get its ASCII value:
DIM SHARED TEMP[10] AS DOUBLE
FOR IDX = 1 TO LOC(1)
TEMP[IDX] = ASC(INPUT$(1,#1))
NEXT IDX
The figure below gives a general description of the TCP/IP communication
for both the client and host.
Open Socket
Client
Server
Close TCP connection
(close socket)
Accept
Connect to specific
port and specific IP
address
Read
Write
Close
Listen to specific
port and accept
connection
Read
Write
Connect
Read
Write
Read
Write
Open TCP connection
(open socket)
1.8.3.5. C
LOSE
C
ONNECTION
CLOSE
closes the connection and releases the device handle:
-->CLOSE #1
10 Rev
E
M-SS-005-03l