用宏去执行读取。
macro_commandmain()
charcommand【32】,response【32】
shortaddress,checksum
shortread_no,return_value,read_data【2】,write_value【2】
FILL(command【0】,0,32) 清零
FILL(response【0】,0,32) 清零
GetData(write_value【0】,"LocalHMI",LW,30,2) 把在触摸屏上输入的值转到触摸屏自定义的数组里
command【0】=0x1 设置从站地址,和Trio的address对应
command【1】=0x10 设置功能码
address=0 为对应写入的地址,为0时,第一个写入的位置为VR(0)
HIBYTE(address,command【2】) 将address的高位写入command数组
LOBYTE(address,command【3】) 将address的低位写入command数组
read_no=2 写入的数有几个,这里为2,表示写入LW30、31
HIBYTE(read_no,command【4】)
LOBYTE(read_no,command【5】)
command【6】 =read_no * 2 应该是等待的意思
HIBYTE(write_value【0】,command【7】)
LOBYTE(write_value【0】,command【8】)
HIBYTE(write_value【1】,command【9】)
LOBYTE(write_value【1】,command【10】)
CRC(command【0】,checksum,11) CRC效验
LOBYTE(checksum,command【11】)
HIBYTE(checksum,command【12】)
OUTPORT(command【0】,"modbusrtu",13) 输出到对应的设备上去
end macro_command