回复 2# aligashiya
刚刚试了下,在宏指令中加入while-wend,连续发送接收10次,delay(100)和delay(10)和之前的效果的一样的。现把宏指定代码贴出来如下:
macro_command main()
unsigned char response[32], command[32],n=0
unsigned short return_value, read_data, temp
// init
FILL(response[0], 0, 32)
FILL(command[0], 0, 32)
command[0] = 0x40 //帧头@
command[1] = 0x40 //帧头@
command[2] = 0x09 //字节数
command[3] = 0x0a //命令字,占用三个字节
command[4] = 0x52
command[5] = 0x44
ADDSUM(command[0],command[6],6) //校验
command[7] = 0x0d //尾
command[8] = 0x0a //尾
while(n<10)
n=n+1
OUTPORT(command[0], "host", command[2])// send command
DELAY(10)
INPORT(response[0], "host", 32, return_value)// read response
SetData(return_value, "Local HMI", RW, 0, 1)// return_value == 0 -> error
if return_value > 0 then
SetData(response[7], "Local HMI", LW, 10, 14)// send response to LW
SetData(response[7], "Local HMI", LW, 17, 1)
SetData(response[7], "Local HMI", LW, 18, 1)
SetData(response[7], "Local HMI", LW, 19, 1)
end if
wend
end macro_command
/******之前代码没有while-wend语句和delay,宏触发用的位状态设置=〉周期切换开关,时间间隔0.1S*****/ |