Java/C# Serial port write to Arduino reading wrong bytes -
i have program wrote in java writes serial port have arduino pro mini plugged into. each chunk of data 6 bytes, , when arduino receivies data, spits out console can see that. problem when data spit out, in wrong order bytes appearing sent twice. wrote same functionality in c# , same thing happening. wrote arduino code write data , echo back, , correct.
so problem must non arduino code, or hardware settings. in code, added delay after every write allows data stay correct while, starts getting screwed up.
i tried messing baud rate, didn't help. why happening??
here's arduino code.
//wait 7 bytes come if (serial.available() >= 7) { /* read recent byte */ serial.print("data: "); //set enable byte data[0] = enable; serial.print((int)data[0], dec); serial.print(" "); for(int = 1; < data_size; i++) { data[i] = serial.read(); serial.print((int)data[i], dec); serial.print(" "); } serial.println(); }
Comments
Post a Comment