FreeCalypso > hg > fc-usbser-tools
comparison cp2102/read_baudtab.c @ 60:ae8075bcc029
cp2102-read-baudtab program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 11 Sep 2023 20:47:52 +0000 |
parents | cp2102/read_eeprom_main.c@d4d3531d342a |
children | 8d35346f1d46 |
comparison
equal
deleted
inserted
replaced
59:672c7adc8bc9 | 60:ae8075bcc029 |
---|---|
1 /* | |
2 * This program locates a CP2102 device via libusb, reads its internal | |
3 * 1024-byte EEPROM, decodes the baud rate table portion thereof | |
4 * and prints the decoded table. | |
5 */ | |
6 | |
7 #include <sys/types.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
12 #include <unistd.h> | |
13 #include <usb.h> | |
14 #include "../libuwrap/find_dev.h" | |
15 #include "cp210x_defs.h" | |
16 | |
17 u_char eeprom[SIZE_EEPROM]; | |
18 | |
19 main(argc, argv) | |
20 char **argv; | |
21 { | |
22 struct usb_device *dev; | |
23 usb_dev_handle *usbh; | |
24 | |
25 if (argc != 2) { | |
26 fprintf(stderr, "usage: %s device-selector\n", argv[0]); | |
27 exit(1); | |
28 } | |
29 dev = find_usbdev_by_desc_string(argv[1]); | |
30 if (!dev) { | |
31 fprintf(stderr, "error: specified USB device not found\n"); | |
32 exit(1); | |
33 } | |
34 usbh = usb_open(dev); | |
35 if (!usbh) { | |
36 fprintf(stderr, "error: usb_open() failed\n"); | |
37 exit(1); | |
38 } | |
39 read_eeprom(usbh); | |
40 usb_close(usbh); | |
41 decode_baud_table(stdout); | |
42 exit(0); | |
43 } |