2 raw meter reader for Linux
4 (C) Andrew Tridgell 2009
9 gcc RawMeterReader.c -o RawMeterReader.exe -lusb-1.0
11 #include <libusb-1.0/libusb.h>
17 int main(int argc, char *argv[])
21 unsigned short vendor_id = 0x1244;
22 unsigned short product_id = 0xd237;
23 libusb_device_handle *h;
25 unsigned char data[14];
26 unsigned char cdata[0x53];
29 libusb_set_debug(ctx, 3);
31 h = libusb_open_device_with_vid_pid(ctx, vendor_id, product_id);
33 fprintf(stderr, "Failed to open DMM device\n");
37 libusb_detach_kernel_driver(h, 0);
39 ret = libusb_claim_interface(h, 0);
41 fprintf(stderr, "Failed to claim interface\n");
45 memset(cdata, 0, sizeof(cdata));
47 ret = libusb_control_transfer(h, 0x80, 0x06, 0x0200, 0, cdata, 0x22, 0);
48 ret = libusb_control_transfer(h, 0x80, 0x06, 0x0200, 0, cdata, 0x22, 0);
49 ret = libusb_control_transfer(h, 0x21, 0x0a, 0x0000, 0, cdata, 0, 0);
50 ret = libusb_control_transfer(h, 0x81, 0x06, 0x2200, 0, cdata, 0x53, 0);
55 memset(data, 0, sizeof(data));
56 ret = libusb_interrupt_transfer(h, 0x81, data, sizeof(data), &nread, 10000);
57 if (ret != 0 || nread != 14) {
58 fprintf(stderr, "libusb_interrupt_transfer ret=%d nread=%d\n", ret, nread);
63 printf("%02X ", data[i]);