jan789
08-25-2016, 02:54 PM
Hi folks, I work on MCP based on Arduino. I read/write offsets through FSUIPC by LUA script. Unfortunately I have one problem. I tried to explain it with parking brake. I have on push button. The code in arduino:
...
void pushButton(){
button = digitalRead(prkgbrake);
if (button == HIGH && exbutton == LOW && millis() - last > ddelay){
Serial.write("brake:1\n")
while( digitalRead(prkgbrake) == HIGH){
}
}
}
...
and this is LUA script
....
x = com.open("COM3", 115200, 0)
function offset(handle, str)
ipc.log(str)
end
event.com(dev, 20, 1, 0, "readSerial")
The problem is that if I push several times push button I get at first correct messages
brake:1
brake:1
brake:1
brake:1
but then I get something like that
brake:1
br
ake:1
brake:1brake:1
brak
e:1
Could someone help me where is the problem, and how to solve it? Thank you in advance :)
...
void pushButton(){
button = digitalRead(prkgbrake);
if (button == HIGH && exbutton == LOW && millis() - last > ddelay){
Serial.write("brake:1\n")
while( digitalRead(prkgbrake) == HIGH){
}
}
}
...
and this is LUA script
....
x = com.open("COM3", 115200, 0)
function offset(handle, str)
ipc.log(str)
end
event.com(dev, 20, 1, 0, "readSerial")
The problem is that if I push several times push button I get at first correct messages
brake:1
brake:1
brake:1
brake:1
but then I get something like that
brake:1
br
ake:1
brake:1brake:1
brak
e:1
Could someone help me where is the problem, and how to solve it? Thank you in advance :)