I have connected a device which sends data over a serial port, through UART and a usb connector.
On my laptop running ubuntu, I have written a C++ program to read this data and store it. It sends 5 lines of 15 bytes, 100 times per second, meaning: 500 lines per second.
I use the standard read command:
while((res += read(IMU, header, 15-res)) < 15);
string head(header, 15);
cout << indexLog << " " << head << endl;
When I read the serial port and read 15 bytes it shows:
0 snp�` �����
0 snp�b#A��H
0 snp�dP�O�^���
0 snp�\����f
0 snp�^���e��M
0 snp�` �����
0 snp�b"����
Where the snp is the beginning of each package. It can be seen that my laptop nicely reads every byte coming in, since every line starts with snp.
I would like to run the same application on my Raspberry PI, for weight and size considerations.
Now when I run the same application on my raspberry PI, I get:
0 �Nsnp�Nsnp
0 Nsnp�\��
0 vsnp�^���
0 np�^�O�
0 vsnp�^�O�
0 np�^�D�
0 ssnp�
0 X�snp�dU
It looks like the Raspberry Pi doesn't read all the bytes, and it becomes a big mess. Trying to salvage useful data results in big data loss.
I already installed a skimmed down version of Raspbian Wheezy and deinstalled X as GUI. But it doesn't seem to make difference.
I believe the Raspberry Pi should be fast enough.
What would be the limiting factor?
Is reading 500 lines (15 bytes) per second over a serial just to much to cope with for the RasPI?
Are there any settings I can change or OS for the Raspberry Pi which can do the job better?
Or is there a way in C++ to read the data more efficient?