# HG changeset patch # User Mychaela Falconia # Date 1694077017 0 # Node ID 1d76deae1e740c79023f73a4fb6c118ca353491c # Parent e1629a7c8ae3294348c6ee71b347e957578e368d fteeprom-read: convert to new local libs diff -r e1629a7c8ae3 -r 1d76deae1e74 fteeprom/Makefile --- a/fteeprom/Makefile Thu Sep 07 08:11:12 2023 +0000 +++ b/fteeprom/Makefile Thu Sep 07 08:56:57 2023 +0000 @@ -2,6 +2,7 @@ CFLAGS= -O2 PROGS= ftee-gen2232c ftee-gen2232h ftee-gen232r ftee-mkblank fteeprom-erase \ fteeprom-prog fteeprom-read +LIBS= ../libftmini/libftmini.a ../libuwrap/libuwrap.a INSTALL_PREFIX= /opt/freecalypso @@ -27,8 +28,8 @@ fteeprom-prog: fteeprom-prog.c ${CC} ${CFLAGS} -o $@ $@.c -lftdi -fteeprom-read: fteeprom-read.c - ${CC} ${CFLAGS} -o $@ $@.c -lftdi +fteeprom-read: fteeprom-read.o ${LIBS} + ${CC} ${CFLAGS} -o $@ $@.o ${LIBS} -lusb install: mkdir -p ${INSTBIN} diff -r e1629a7c8ae3 -r 1d76deae1e74 fteeprom/fteeprom-read.c --- a/fteeprom/fteeprom-read.c Thu Sep 07 08:11:12 2023 +0000 +++ b/fteeprom/fteeprom-read.c Thu Sep 07 08:56:57 2023 +0000 @@ -1,10 +1,20 @@ +/* + * This program connects to an FTDI chip via libusb and reads out its EEPROM. + * The present version has been converted to use our local libraries + * (libftmini and libuwrap) instead of libftdi - thus the external dependency + * is only libusb. + */ + #include #include #include #include #include #include -#include +#include +#include "../libuwrap/find_dev.h" +#include "../libuwrap/open_close.h" +#include "../libftmini/eeprom_func.h" char *device_selector; unsigned eeprom_size = 64; @@ -39,22 +49,20 @@ main(argc, argv) char **argv; { - struct ftdi_context ftdi; + struct usb_device *dev; + usb_dev_handle *usbh; u_short word; unsigned n, col; process_cmdline(argc, argv); - ftdi_init(&ftdi); - if (ftdi_usb_open_string(&ftdi, device_selector) < 0) { - fprintf(stderr, "FTDI USB open failed: %s\n", ftdi.error_str); + dev = find_usbdev_by_desc_string(device_selector); + if (!dev) { + fprintf(stderr, "error: specified USB device not found\n"); exit(1); } + usbh = usbwrap_open_dev(dev, 1); for (n = 0; n < eeprom_size; n++) { - if (ftdi_read_eeprom_location(&ftdi, n, &word) < 0) { - fprintf(stderr, "EEPROM read error: %s\n", - ftdi.error_str); - exit(1); - } + word = ftmini_read_eeprom_loc(usbh, n); col = n & 7; if (col == 0) printf("%02X:", n * 2); @@ -62,6 +70,6 @@ if (col == 7) putchar('\n'); } - ftdi_usb_close(&ftdi); + usbwrap_close_dev(usbh); exit(0); }