macro_command main()
char command[32], response[32]
short address, checksum
short read_no, return_value, read_data[2]
INPORT(response[0], "MODBUS RTU Device", 9, return_value)
if return_value > 0 then//判断接收字节大于0
read_data[0] = response[4] + (response[3] << 8) //提取第1个字,先把字节左移动8位变高字节,然后高低相加
read_data[1] = response[6] + (response[5] << 8) // 提取第2个字,先把字节左移动8位变高字节,然后高低相加
SetData(read_data[0], "Local HMI", LW, 100, 2)
end if
end macro_command