From: michael Date: Mon, 2 Apr 2007 08:22:08 +0000 (+0000) Subject: Add hack to force the detection of a parallel cable by Stefan Ziegenbalg. X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/commitdiff_plain/cdc9c5bf0932e07ed1a19bd7315bad79a2a41b4c Add hack to force the detection of a parallel cable by Stefan Ziegenbalg. This hack is activated by preloading libusb-driver-trenz.so. --- diff --git a/Makefile b/Makefile index 4ef6aba..3325a89 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,19 @@ -CFLAGS=-Wall +CFLAGS=-Wall -fPIC -all: libusb-driver.so libusb-driver-DEBUG.so +SOBJECTS=libusb-driver.so libusb-driver-DEBUG.so libusb-driver-trenz.so + +all: $(SOBJECTS) libusb-driver.so: usb-driver.c usb-driver.h - gcc -fPIC $(CFLAGS) $< -o $@ -ldl -lusb -lpthread -shared + gcc $(CFLAGS) $< -o $@ -ldl -lusb -lpthread -shared + +libusb-driver-trenz.so: usb-driver.c usb-driver.h + gcc -DTRENZ $(CFLAGS) $< -o $@ -ldl -lusb -lpthread -shared libusb-driver-DEBUG.so: usb-driver.c usb-driver.h - gcc -fPIC -DDEBUG $(CFLAGS) $< -o $@ -ldl -lusb -lpthread -shared + gcc -DDEBUG $(CFLAGS) $< -o $@ -ldl -lusb -lpthread -shared clean: - rm -f libusb-driver.so libusb-driver-DEBUG.so + rm -f $(SOBJECTS) .PHONY: clean all diff --git a/README b/README index 13737b5..fcf211a 100644 --- a/README +++ b/README @@ -72,6 +72,11 @@ ppdev To use the device as an ordinary user, put the user in the group 'lp' +If you have an almost compatible cable which works with other software but not +with Impact, try preloading libusb-driver-trenz.so instead of libusb-driver.so. +It includes a hack by Stefan Ziegenbalg to force detection of a parallel cable. + + Parallel Cable IV is currently only supported in 'compatibility mode', as no attempt to configure the ECP registers is done by this library. diff --git a/usb-driver.c b/usb-driver.c index fa2611e..c497b50 100644 --- a/usb-driver.c +++ b/usb-driver.c @@ -241,6 +241,7 @@ int pp_transfer(WD_TRANSFER *tr, int fd, unsigned int request, unsigned char *wd int ret = 0; unsigned long port = (unsigned long)tr->dwPort; unsigned char val; + static int last_pp_write = 0; DPRINTF("dwPort: 0x%lx, cmdTrans: %lu, dwbytes: %ld, fautoinc: %ld, dwoptions: %ld\n", (unsigned long)tr->dwPort, tr->cmdTrans, tr->dwBytes, @@ -268,6 +269,7 @@ int pp_transfer(WD_TRANSFER *tr, int fd, unsigned int request, unsigned char *wd case PP_WRITE: ret = ioctl(parportfd, PPWDATA, &val); + last_pp_write = val; break; default: @@ -276,10 +278,17 @@ int pp_transfer(WD_TRANSFER *tr, int fd, unsigned int request, unsigned char *wd break; } } else if (port == ppbase + PP_STATUS) { - DPRINTF("status port\n"); + DPRINTF("status port (last write: %d)\n", last_pp_write); switch(tr->cmdTrans) { case PP_READ: ret = ioctl(parportfd, PPRSTATUS, &val); +#ifdef TRENZ + val &= 95; + if (last_pp_write & 64) + val |= 32; + else + val |= 128; +#endif break; case PP_WRITE: