Can anybody compile a program for me which runs on Home Assistant Operating System

Hello,
I’m looking for someone who is able to compile this program so that it’s possible to use it on my Home Assistant Operating System.

This is the code:

/* usbreset -- send a USB port reset to a USB device */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>

#include <linux/usbdevice_fs.h>


int main(int argc, char **argv)
{
    const char *filename;
    int fd;
    int rc;

    if (argc != 2) {
        fprintf(stderr, "Usage: usbreset device-filename\n");
        return 1;
    }
    filename = argv[1];

    fd = open(filename, O_WRONLY);
    if (fd < 0) {
        perror("Error opening output file");
        return 1;
    }

    printf("Resetting USB device %s\n", filename);
    rc = ioctl(fd, USBDEVFS_RESET, 0);
    if (rc < 0) {
        perror("Error in ioctl");
        return 1;
    }
    printf("Reset successful\n");

    close(fd);
    return 0;
}

The command to compile would be

cc usbreset.c -o usbreset

I would be really happy if somebody could help me getting this running.

Thanks!

As it’s better to teach how to fish:

  • Enter the terminal on your docker (Terminal+SSH addon);
  • Install the required packages - A quick method is apk add build-base;
  • You can execute your command, but you’ll have to fix ‘fatal error: linux/usbdevice_fs.h: No such file or directory’
  • EDIT: you can fix that with apk add linux-headers.
1 Like

Thanks a lot, I wil ltry this!