0

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?

  • How is the serial connection made to the Raspberry PI? Also via USB? What device are you reading from? – HeatfanJohn Dec 30 '13 at 23:59
  • 1
    Also, what kind of serial interface are you using (FTDI, Prolific, or other?) Flow control type? 75kbit/s should be doable, but it depends on your system load, among other things. – scruss Dec 31 '13 at 3:52
  • I am using a pololu usb01b serial to usb converter, and I am reading from an IMU device (the CHR UM6) which measures attitude, velocities and accelerations. I tried to keep the raspberry as clean as possible installing a minimal version without GUI. – Ferdinand Peters Dec 31 '13 at 10:05
  • in python normally we empty system buffers to force sync data with our destination file to prevent data loss dunno whtsup with c++ – Ruthvik Vaila Jan 1 '14 at 2:16
2

If you are using USB Serial Converter, make sure it is capable of keeping signal level at 12V. Cheap USB to serial dongles may not have proper level shifting and keep signal at USB signal level, which is only 5V. It makes signal reception unstable, similar to what you are seeing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.