From 4a8d380999698852164f09801cdbc8346f5a42e8 Mon Sep 17 00:00:00 2001 From: pete-cs Date: Wed, 19 Jun 2013 20:55:45 +0000 Subject: [PATCH] turn ftdi driver into echo server git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1612 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/USBFtdi.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/client/USBFtdi.py b/client/USBFtdi.py index 0302ac1..abc5980 100644 --- a/client/USBFtdi.py +++ b/client/USBFtdi.py @@ -137,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 ) ] @@ -155,11 +155,16 @@ class USBFtdiInterface(USBInterface): descriptors ) - def handle_buffer_available(self): - pass - def handle_data_available(self, data): - print(bytes_as_hex(data)) + 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): -- 2.20.1