comparison controlmsg.c @ 0:71b9540bdd23

starting, importing Woo's code and adding minimon
author Peter Meerwald <pmeerw@pmeerw.net>
date Sat, 07 May 2011 17:29:58 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:71b9540bdd23
1 /* $Id: usbreplay.c,v 1.7 2004/02/07 17:02:32 bd Exp $ */
2 /* Use only with the Hauppauge WinTV PVR usb2, VID/PID 2040/2900. */
3 /* No commercial affiliation, warranty, copyright, party invitation, */
4 /* fitness or non-fitness, implied or otherwise, is claimed by this comment. */
5 /* Compile with -lusb, then put it where capture.pl will find it. */
6
7 #include <usb.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <fcntl.h>
12
13 struct usb_device *find_first_pvr() {
14 struct usb_bus *bus;
15 struct usb_device *dev;
16
17 usb_init();
18 usb_find_busses();
19 usb_find_devices();
20
21 for (bus = usb_busses; bus; bus = bus->next) {
22 for (dev = bus->devices; dev; dev = dev->next) {
23 if (dev->descriptor.idVendor == 0x04e8 &&
24 dev->descriptor.idProduct == 0x2027) {
25 fprintf(stderr, "Samsung photoframe in Mass Storage mode found ...\n");
26 return dev;
27 }
28 else if (dev->descriptor.idVendor == 0x04e8 &&
29 dev->descriptor.idProduct == 0x2028){
30 fprintf(stderr, "Samsung photoframe in Custom Product mode found ...\n");
31 return NULL;
32 }
33 }
34 }
35 fprintf(stderr, "No Samsung device found ...\n");
36 return NULL;
37 }
38
39
40 int replay() {
41 int res = -1;
42 char buf[256];
43 usb_dev_handle *udev;
44 struct usb_device *dev = NULL;
45 int numeps = 0;
46
47 dev = find_first_pvr();
48 if (dev == NULL) {
49 fprintf(stderr, "Since no Samsung device in Mass Storage mode found, not going to do anything\n");
50 return 0;
51 }
52 udev = usb_open(dev);
53
54 setuid(getuid());
55
56 strcpy(buf, "** no string **");
57 res = usb_get_string_simple(udev, dev->descriptor.iManufacturer, buf, sizeof(buf));
58 fprintf(stderr, "usb_get_string_simple => %d, %s\n", res, buf);
59
60 char blah[254];
61 memset(blah,0,254);
62
63 res = usb_control_msg(udev, USB_TYPE_STANDARD | USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, 0xfe, 0xfe, blah, 0xfe, 1000);
64 printf("usb_control_msg() = %d\n",res);
65
66 fprintf(stderr, "Just switched to 0x2028 Custom Product mode\n");
67 return 0;
68 }
69
70
71 int main(int argc, char *argv[]) {
72 return replay();
73 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.