Mercurial > hg > minimon
diff minimon.c @ 2:bac8ed8d6eb9
add jpeg coding and test stuff
author | Peter Meerwald <pmeerw@pmeerw.net> |
---|---|
date | Sun, 08 May 2011 18:22:22 +0200 |
parents | 111d4bbce605 |
children | 078dc69945ad |
line wrap: on
line diff
--- a/minimon.c Sat May 07 19:00:43 2011 +0200 +++ b/minimon.c Sun May 08 18:22:22 2011 +0200 @@ -18,10 +18,11 @@ int height; } id_info_t; +// there are many more, static id_info_t ids[] = { - {0x2027, 0x2028, }, + {0x2027, 0x2028, "SPF-107H", 1024, 600}, {0xffff, 0xffff, "SPF-75H", 800, 480}, - {0xffff, 0xffff, "SPF-83H", 800, 600}, // 85P?? + {0xffff, 0xffff, "SPF-83H", 800, 600}, {0xffff, 0xffff, "SPF-85H", 800, 600}, // 85P?? {0x2033, 0x2034, "SPF-87H", 800, 480}, {0x2035, 0x2036, "SPF-107H", 1024, 600}, @@ -76,7 +77,6 @@ static usb_dev_handle *dev_open(struct usb_device *dev) { int res = -1; - char buf[256]; usb_dev_handle *udev; int numeps = 0; @@ -86,7 +86,7 @@ exit(EXIT_FAILURE); } - setuid(getuid()); +// setuid(getuid()); res = usb_set_configuration(udev, 1); @@ -97,10 +97,6 @@ exit(EXIT_FAILURE); } - strcpy(buf, "** no string **"); - res = usb_get_string_simple(udev, dev->descriptor.iManufacturer, buf, sizeof(buf)); - // fprintf(stderr, "usb_get_string_simple => %d, %s\n", res, buf); - { int eplist[] = { 0x2, 0x81, 0x83 }; int eplength = sizeof(eplist)/sizeof(eplist[0]); @@ -179,6 +175,7 @@ fprintf(stderr, "%s: usb_control_msg() = %d\n", progname, res); usb_close(udev); + usleep(500000); } dev = find_dev(index); @@ -192,10 +189,6 @@ usb_dev_handle *udev = dev_open(dev); -// int res = usb_control_msg(udev, USB_TYPE_STANDARD | USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, -// 0xfe, 0x0, buf, 0x0, 1000); -// fprintf(stderr, "%s: usb_control_msg() = %d\n", progname, res); - FILE *f = fopen(argv[1], "rb"); if (f == NULL) { fprintf(stderr, "%s: failed to open file '%s', exit.\n", progname, argv[1]); @@ -204,5 +197,16 @@ send_jpeg(f, udev); fclose(f); + while (1) { + char buf[2]; + int res = usb_control_msg(udev, USB_TYPE_VENDOR | USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, + 0x0, 0x0, buf, 0x2, 1000); + fprintf(stderr, "%s: usb_control_msg() = %d\n", progname, res); + + usleep(500000); + } + + usb_close(udev); + return EXIT_SUCCESS; }