Communication protocols
PROGRAMMING MANUAL
215
R
e
vi
si
o
n
1
.0
Set up
You need the
SETCOM
command to set up the serial port of the TJ2-MC64
for the Host Link Master protocol. Set the command as follows:
SETCOM(baudrate, data_bits, stop_bits, parity, port, 6)
After you have set this command, you can use the
HLM_READ
,
HLM_WRITE
and
HLM_COMMAND
commands to read and write data
using Host Link.
Timeout
The timeout mechanism is implemented to prevent that the BASIC task
pauses for a long time due to bad or no communication. The
HLM_TIMEOUT
parameter specifies the timeout period. This period is the
maximum time the program task waits after it has sent the command to
receive a response.
If the timeout period elapses, the
HLM_STATUS
contains the status of the
command, and the BASIC task continues.
The
HLM_TIMEOUT
parameter specifies the timeout period for all
commands and for all ports.
Status
The
HLM_STATUS
parameter contains the status of the last Host Link
master command sent to the specified port. The parameter indicates the
status for the
HLM_READ
,
HLM_WRITE
and
HLM_COMMAND
commands. The status bits are:
/i
The HLM_STATUS has value 0 when no problems occurred. In case of a
non-zero value you need to program an appropriate action such as a retry or
emergency stop in the user BASIC program. Each port has an
HLM_STATUS parameter. You need the
PORT
modifier to specify the port.
$14
Format error
•
The command format is
wrong.
•
A command that cannot be
divided has been divided.
•
The frame length is smaller
than the minimum length for
the applicable command.
Check the format and
transfer the command
again.
$15
Entry number
data error
The data is outside the specified
range or too long.
Correct the command
arguments and trans-
fer the command
again.
$18
Frame length
error
The maximum frame length of
131 bytes is exceeded.
Check the command
and transfer the com-
mand again.
$19
Not executable
You did not obtain access rights.
Obtain access rights.
$21
Not executable
due to CPU
error.
The command cannot be exe-
cuted because a CPU error has
occurred.
Cycle the power sup-
ply of the CPU.
$100
Host Link slave
ACK timeout
-
-
$200
IC command
address error
-
-
End code
Description
Probable cause
Solution
Bit
Name Description
0-7
End code
The end code is:
•
the end code defined by the Host Link slave, when a prob-
lem occurred in the data string of the sent command, or
•
an end code defined by the Host Link master, when a prob-
lem occurred in the data string of the received response.
8
Timeout error
A timeout error occurs if no response is received within the time-
out period. This indicates that the communication is lost.
9
Command not
recognised
This status indicates that the slave did not recognise the com-
mand and has returned an IC response.