BrickPi_C BrickPiSetupSensor return -1 randomly

Hello,

I have encountered an issue that I can’t quite understand on my BrickPi:

I first tried the Python library for BrickPi on my motors with the example in the SensorExamples directory. Everything seems to work perfectly without any problems.

Then, I tried using the C library for BrickPi. The first time I ran the example programm for the motors, it seems to run without problems. After my first Sigkill (Ctrl+C) for the program, I tried to rerun it and got the error :

BrickPiSetup: 0
BrickPiSetupSensors: -1

From now on (until I restart the Raspberry Pi), the program mostly returns the same error but sometimes it succeed to start the motors…

This pattern repeats itself after every reboot of my RPi. I’m using the last library from the BrickPi_C GIT.

Edit: Some tries with gdb shows that the built message for BrickPiTx is the same between C and Python. It’s seems that my BrickPiRx fails sometimes in C (mostly Timeout) and when the motors start running after a reboot, I got some errors too in Rx (-4 and -5).

Thank you.

Hey Nexus, sorry to hear about this. I’ll have to look at the C library again, it seems the communication might be timing out too quickly with it. Good to know it’s not a hardware problem though. The C drivers may have fallen behind a bit in updates.

Hi John,

Thanks for your reply,

I checked with an oscilloscope the TX and RX pins of the GPIO. The C Library doesn’t send anything, while the Python Library is sending the right data on both RX and TX.

I also tried sending data manually on the TX with :

echo -e -n "test\x00" > /dev/ttyAMA0

and the oscilloscope got the signal.

I guess that the serial functions doesn’t work. Any idea why ?

Thanks

Ok, great. Narrowed down to the C functions. Are you using Raspbian for Robots, or did you install on plain Raspbian?

I installed Raspbian for Robot.

Great, version? Is it the latest 2015.11.xx or an earlier 2015.03.20 version?

They bought the SD card from your shop in October (http://www.dexterindustries.com/shop/sd-card-raspbian-wheezy-image-for-raspberry-pi/) so I’m using the version installed on it.

Edit : I checked, the version is 2015.03.20

Seems this bug is still around,
I cant get any reading with BrickPi_C code, although BrickPi_Python seems to work fine,
I can successfully run Lego motors (with C and Python both) but Python is only one able to read Ultrasonic sensor (NXT), while C does gives just
BrickPiSetup: 0
BrickPiSetupSensors: -1

@tarmoaia, just to confirm: the BrickPi Python files run the motors and sensors fine, but when you try to run the C program with one ultrasonic sensor, you get back a 0 on setup, is that right?

@JohnC
Correct, BrickPiSetup returns zero, but BrickPiSetupSensors will return -1,
If I disable the sensors setup line in code i can run motors with C code