X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FUSBFtdi.py;h=abc5980a987e7c41323a69f8365fd67d8f1122c6;hp=b7e966b791c46c40bb4ec0eceaccc1206c57a717;hb=HEAD;hpb=cbeb6463f500756b9c33789018dffc922a7d9ec0 diff --git a/client/USBFtdi.py b/client/USBFtdi.py index b7e966b..abc5980 100644 --- a/client/USBFtdi.py +++ b/client/USBFtdi.py @@ -38,10 +38,10 @@ class USBFtdiVendor(USBVendor): if self.verbose > 0: print(self.name, "received modem_ctrl request") - dtr = req.value[1] & 0x01 - rts = (req.value[1] & 0x02) >> 1 - dtren = req.value[0] & 0x01 - rtsen = (req.value[0] & 0x02) >> 1 + dtr = req.value & 0x0001 + rts = (req.value & 0x0002) >> 1 + dtren = (req.value & 0x0100) >> 8 + rtsen = (req.value & 0x0200) >> 9 if dtren: print("DTR is enabled, value", dtr) @@ -54,14 +54,13 @@ class USBFtdiVendor(USBVendor): if self.verbose > 0: print(self.name, "received set_flow_ctrl request") - dtr = req.value[1] & 0x01 - if req.value[1] == 0: + if req.value == 0x000: print("SET_FLOW_CTRL to no handshaking") - if req.value[1] & 0x01: + if req.value & 0x0001: print("SET_FLOW_CTRL for RTS/CTS handshaking") - if req.value[1] & 0x02: + if req.value & 0x0002: print("SET_FLOW_CTRL for DTR/DSR handshaking") - if req.value[1] & 0x04: + if req.value & 0x0004: print("SET_FLOW_CTRL for XON/XOFF handshaking") self.device.maxusb_app.send_on_endpoint(0, b'') @@ -70,8 +69,8 @@ class USBFtdiVendor(USBVendor): if self.verbose > 0: print(self.name, "received set_baud_rate request") - dtr = req.value[1] & 0x01 - print("baud rate set to", req.value[1]) + dtr = req.value & 0x0001 + print("baud rate set to", dtr) self.device.maxusb_app.send_on_endpoint(0, b'') @@ -138,7 +137,7 @@ class USBFtdiInterface(USBInterface): USBEndpoint.usage_type_data, 16384, # max packet size 0, # polling interval, see USB 2.0 spec Table 9-13 - self.handle_buffer_available # handler function + None # handler function ) ] @@ -156,11 +155,16 @@ class USBFtdiInterface(USBInterface): descriptors ) - def handle_buffer_available(self): - pass - def handle_data_available(self, data): - pass + s = data[1:] + if self.verbose > 0: + print(self.name, "received string", s) + + s = s.replace(b'\r', b'\r\n') + + reply = b'\x01\x00' + s + + self.configuration.device.maxusb_app.send_on_endpoint(3, reply) class USBFtdiDevice(USBDevice): @@ -182,8 +186,8 @@ class USBFtdiDevice(USBDevice): 0, # device subclass 0, # protocol release number 64, # max packet size for endpoint 0 - 0x0304, # vendor id: FTDI - 0x0160, # product id: FT232 USB-Serial (UART) IC + 0x0403, # vendor id: FTDI + 0x6001, # product id: FT232 USB-Serial (UART) IC 0x0001, # device revision "GoodFET", # manufacturer string "FTDI Emulator", # product string