#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <libusb.h>
ret = libusb_init(NULL);
if (ret < 0) {
- fprintf(stderr, "error (%d): cannot initialize libusb.\n", ret);
+ fprintf(stderr, "libusb_init failed: %s\n", libusb_error_name(ret));
goto out;
}
VISOMAT_DEVICE_VID,
VISOMAT_DEVICE_PID);
if (dev == NULL) {
- fprintf(stderr, "error (%d): cannot open device.\n", errno);
+ fprintf(stderr, "libusb_open failed: %s\n", strerror(errno));
ret = -errno;
goto out_libusb_exit;
}
ret = libusb_set_configuration(dev, VISOMAT_CONFIGURATION);
if (ret < 0) {
- fprintf(stderr, "error (%d): cannot set configuration %d.\n",
- ret, VISOMAT_CONFIGURATION);
+ fprintf(stderr, "libusb_set_configuration failed: %s\n",
+ libusb_error_name(ret));
+ fprintf(stderr, "Cannot set configuration %hhu\n",
+ VISOMAT_CONFIGURATION);
goto out_libusb_close;
}
ret = libusb_claim_interface(dev, VISOMAT_INTERFACE);
if (ret < 0) {
- fprintf(stderr, "error (%d): cannot claim interface %d.\n",
- ret, VISOMAT_INTERFACE);
+ fprintf(stderr, "libusb_claim_interface failed: %s\n",
+ libusb_error_name(ret));
+ fprintf(stderr, "Cannot claim interface %hhu\n",
+ VISOMAT_INTERFACE);
goto out_libusb_close;
}