用RS485做了个自由口通讯的,每次上电后,第一次发送字符串的时候都是乱码或者乱码+正常字符串,但是第二次开始就是正常的,几乎每次上电第一次都是这样,是什么问题啊?附上宏指令:
macro_command main()
char command[32]
bool SOT,EOT
char response[32]
short input_data1,n1
int input_data2
FILL(command[0], 0, 32)
GetData(SOT, "OMRON CJ1/CS1", W_Bit, 6000, 1)
if SOT == 1 then
GetData(input_data1, "OMRON CJ1/CS1", D, 15000, 1)
GetData(input_data2, "OMRON CJ1/CS1", D, 15002, 1)
n1 = 0
command[0] = '{'
command[5] = ','
//command[6] = 0x7f
command[10] = ','
//command[12] = 0x7f
command[19] = '}'
DEC2ASCII(input_data1, command[1], 4)
DEC2ASCII(input_data1, command[6], 4)
DEC2ASCII(input_data2, command[11], 8)// no. of ASCII == 5
OUTPORT(command[0], "MODBUS RTU Device", 20)
SOT = 0
SetData(SOT, "OMRON CJ1/CS1", W_Bit, 6000, 1)
end if
end macro_command