I finally found out why my data was sometimes chopped.
See: C++ Serial Communication - Programming Questions - Arduino Forum
The serial monitor is perfectly fine but reading the data using the SerialClass, I get incomplete string.
Now, why is it not EXPLICITLY mentioned that one should PROBABLY iterate the readSerialPort function until the packet has been completely sent? Hell, even hard code delimiter to enforce the use of a proper way of sending data.
I saw a lot of question on the subject and C++ is definitely worth supporting a bit better.
The Arduino Playground was a publicly editable wiki. The content is all written by the Arduino community. For this reason, the quality of the information varies. A year ago, Arduino decided to make the Arduino Playground read-only due to concerns about security vulnerabilities in the outdated wiki software it uses. If you have specific suggestions for improvements or corrections, please submit a ticket via this form:
pert:
The Arduino Playground was a publicly editable wiki. The content is all written by the Arduino community. For this reason, the quality of the information varies. A year ago, Arduino decided to make the Arduino Playground read-only due to concerns about security vulnerabilities in the outdated wiki software it uses. If you have specific suggestions for improvements or corrections, please submit a ticket via this form: Arduino Official Store | Boards Shields Kits Accessories
Thanks, will do.
Power_Broker:
You might have more luck using this library in your C++ console application (assuming you're using Windows).
That being said, it's a whole lot easier to do serial communication in Python!
Will definitely check it out, thanks. I love Python but C++ is a requirement.
Power_Broker:
Note that the C++ app code proposed by that tutorial only works on Linux machines like the RPi. Is that what you're running your C++ app on?
No, I'm running windows. I should have mentioned that I'm not reusing the code, just implementing the concept with SerialClass given in the first post. I'd like to improve the protocol with checksum. I'll send a ticket once I'll be satisfied with the solution. In the meantime I felt like closing this thread with some relevant information how to proceed, which was left out from the SerialClass tutorial.