in4lio / ev3dev-c

LEGO MINDSTORMS EV3 Debian C library + Python, Ruby and Perl wrappers
MIT License
71 stars 30 forks source link

Can the library be used for RaspberryPi/BrickPi #35

Closed r0bis closed 2 years ago

r0bis commented 2 years ago

I am starting to try to program in C - the advice from ev3dev is to use this library. I managed to set up cross compilation working quite well (writeup on stackexchange) and examples compile and run on EV3 brick, but not so on BrickPi3. I understand that the issue probably is that BrickPi does not autodetect sensors or motors.

Is there a simpler sample program in C that would use sensors/motors without autodetection (int ev3_tacho_init() does not return anything). I cannot yet work it out from the doxygen generated documentation. I am sorry, too complex for a beginner.

In other words - how to deal with no autodetection. Brickpi for example does not create

robot@ev3dev:~/src$ cat /sys/class/lego-sensor/sensor2/driver_name 
lego-ev3-ir

This above works on EV3 device but not on BrickPi :-(

r0bis commented 2 years ago

OK, there was something wrong with brickpi3 module - I managed to sort it out with help from @dlech and the struggle can be seen here https://github.com/ev3dev/ev3dev/issues/1534#event-6738268871
Brickpi - once it is running properly - will create things like:

root@ev3dev:/home/robot# cat /sys/class/lego-port/port4/driver_name 
brickpi3-out-port
root@ev3dev:/home/robot# cat /sys/class/tacho-motor/motor0/driver_name 
lego-nxt-motor

it is just that the motor driver is there as a default thing and in code you have to specify this by number for example set_tacho_command_inx( 3, TACHO_RUN_TIMED );