31 lines
755 B
C
31 lines
755 B
C
#ifndef UTILS_H_
|
|
#define UTILS_H_
|
|
|
|
#define ASSERT(line) do { \
|
|
int r = line; \
|
|
if (r < LIBUSB_SUCCESS && r < LIBUSB_ERROR_COUNT) { \
|
|
printf("%s (%d) on %s:%d\n%s\n", libusb_error_name(r), r, __FILE__, __LINE__, #line);\
|
|
} \
|
|
} while (0)
|
|
|
|
#define ASSERT_RETURN(line, ret) do { \
|
|
int r = line; \
|
|
if (r < LIBUSB_SUCCESS) { \
|
|
printf("%s on %s:%d\n%s\n", libusb_error_name(r),__FILE__, __LINE__, #line);\
|
|
return ret;\
|
|
} \
|
|
} while (0)
|
|
|
|
#include <stdlib.h>
|
|
#include <inttypes.h>
|
|
|
|
typedef struct {
|
|
uint16_t value;
|
|
char* name;
|
|
} skillerctl_name_value_pair_t;
|
|
|
|
void hexdump(void* bytes, size_t length);
|
|
uint16_t skillerctl_lut_search(skillerctl_name_value_pair_t *lut, size_t n, const char* name);
|
|
|
|
#endif
|