0

I wrote software in C for my work that reads Logitech F310 controller input and controls our vehicle accordingly. I wanted my software to be fault-tolerant, so I added code that checks the presence of the joystick and attempts to open the controller file again. The loop looks pretty much like this (simplified):

if(joystick_status == CONNECTED) {
    if( access("/dev/input/js0", F_OK ) == -1 ) {
        joystick_status = DISCONNECTED;
    }
} else {
    *joystick = open("/dev/input/js0", O_NONBLOCK);
    if(*joystick == -1) {
        //failed to open the joystick file
    } else {
        joystick_status = CONNECTED;
    }
}

I hope this is enough for people to understand what I am trying to do. I want to check the joystick connection, and if the device is disconnected, I attempt to open the "/dev/input/js0" file.

I wrote this software using Raspberry Pi 3B+, cloned the microSD card, and used the new microSD card with a Raspberry Pi Zero W. Thus, the code and the Linux environment are the same on both hardware. When every device is connected before the Linux boots up, the software runs perfectly fine on both hardware.

However, Raspberry Pi Zero W has an issue reading the joystick value if the controller is hot-plugged. While it is capable of reading the joystick presence, my software does not respond to the controller inputs. I have confirmed that I can hot-plug the controller on runs perfectly OK on the Pi 3B+ using the same microSD card I used to test the software on the Pi Zero W.

Could anybody suggest what may be causing this issue, please?

  • Yes, I found a couple of drivers working on Rpi3B+ does not work on RpiZ and RpiZW. – tlfong01 Sep 5 at 1:21
  • So it is most likely the USB driver issue. Do you think there's any way to achieve my goal? Maybe trying a different USB driver or et cetera. – HumbleBumble Sep 5 at 15:39

Your Answer

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

Browse other questions tagged or ask your own question.