CFLAGS += -Wunsafe-loop-optimizations -Wunused-but-set-variable
endif
+ifeq ($(DEBUG),1)
+ CFLAGS += -DDEBUG
+endif
+
CFLAGS += $(shell pkg-config --cflags libusb-1.0)
LDLIBS := $(shell pkg-config --libs libusb-1.0)
#include <unistd.h>
#include <libusb.h>
+#ifdef DEBUG
+#define debug(...) fprintf(stderr, __VA_ARGS__)
+static void debug_dump_buffer(const char *filename, uint8_t *buffer, unsigned int len)
+{
+ FILE *dump_file;
+
+ dump_file = fopen(filename, "wb");
+ if (dump_file == NULL) {
+ fprintf(stderr, "Failed to open %s: %s\n", filename, strerror(errno));
+ return;
+ }
+
+ fwrite(buffer, 1, len, dump_file);
+ fclose(dump_file);
+}
+#else
+#define debug(...) do {} while(0)
+static void debug_dump_buffer(const char *filename, uint8_t *buffer, unsigned int len)
+{
+ (void)filename;
+ (void)buffer;
+ (void)len;
+}
+#endif
+
#define VISOMAT_DEVICE_VID 0x1247
#define VISOMAT_DEVICE_PID 0x00f8
#define VISOMAT_CONFIGURATION 1
if (ret < 0)
return ret;
+ debug("buffer len: %d\n", ret);
+ debug_dump_buffer("eeprom.bin", buffer, sizeof(buffer));
+
ret = decode_eeprom(buffer, ret, user_mask);
if (ret < 0)
return ret;