can you count the letter o in:
when i send the data via serial monitor of arduino there is no garbage data.
this is the only thing i have not changed yet and i dont want to change this as the string length will increase over time. this is 43 bytes of data. it can grow to up-to around 64 or 100 bytes and that would take longer to send and even longer to read adding delays in functions that are already working before the serial interrupt.
the arduino should read only whole lines (non-newlines until a newline). discard the line if it doesnt start with stat>.
this will make your program more robust and less likely to fail with bad input. fixing the transmitting app instead still leaves your arduino vulnerable.
consider the rule of thumb for serial communication: be restrictive in what youll transmit; be lax in what youll receive. specify your communication protocol (e.g. packets will begin with stat> and end with <newline>, maximum length of a packet, formats of variables and numbers, etc.). then write your sender to hold as tightly to the spec as possible and write your receiver to accept whatever minor variations in otherwise good packets, that wont cause you to mistakenly accept bad ones. this principle will make your communications systems more robust and easier to get working in the first place.
not the answer youre looking for? browse other questions tagged arduino-uno serial visualstudio c# or ask your own question.
user
The total number of "o"s in that passage is ninety-one.
assistant