Compare commits
1
Commits
3a5ac05d9d
...
doublebuf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb8d3d29bf
|
+2
-1
@@ -48,7 +48,8 @@ class Client:
|
||||
pld_as_s = msg.data.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
pld_as_s = str(msg.data)
|
||||
raise Exception("UNHANDLED MESSAGE! %s" % pld_as_s)
|
||||
# raise Exception("UNHANDLED MESSAGE! %s, type %d, id %04x" % (' '.join([("%02x"%b) for b in msg.data]), msg.type, msg.id))
|
||||
print("UNHANDLED MESSAGE! %s, type %d, id %04x" % (' '.join([("%02x" % b) for b in msg.data]), msg.type, msg.id))
|
||||
|
||||
self.tf.add_fallback_listener(fallback_lst)
|
||||
|
||||
|
||||
@@ -142,6 +142,8 @@ class TinyFrame:
|
||||
if listener is not None:
|
||||
self.add_id_listener(id, listener)
|
||||
|
||||
print("Tx: " + ' '.join(["%02x"%b for b in buf]))
|
||||
print(" " + ''.join(["%c"% (b if b>=32 and b<127 else ord('.')) for b in buf]))
|
||||
self.write(buf)
|
||||
return id
|
||||
|
||||
@@ -187,6 +189,9 @@ class TinyFrame:
|
||||
"""
|
||||
Parse bytes received on the serial port
|
||||
"""
|
||||
print("Rx: " + ' '.join(["%02x"%b for b in bytes]))
|
||||
print(" " + ''.join(["%c"% (b if b>=32 and b<127 else ord('.')) for b in bytes]))
|
||||
|
||||
for b in bytes:
|
||||
self.accept_byte(b)
|
||||
|
||||
@@ -233,6 +238,7 @@ class TinyFrame:
|
||||
|
||||
if len(self.rbuf) == self.rlen:
|
||||
self.rf.len = self._unpack(self.rbuf)
|
||||
print("Len=%d"%self.rf.len)
|
||||
|
||||
self.ps = 'TYPE'
|
||||
self.rlen = self.TYPE_BYTES
|
||||
|
||||
+2
-1
@@ -150,6 +150,7 @@ class TrxRawUSB (BaseGexTransport):
|
||||
|
||||
detach_kernel_driver(dev, 2) # CDC data
|
||||
detach_kernel_driver(dev, 3) # CDC control
|
||||
detach_kernel_driver(dev, 4) # CDC data2
|
||||
|
||||
# Set default configuration
|
||||
# (this will fail if we don't have the right permissions)
|
||||
@@ -188,7 +189,7 @@ class TrxRawUSB (BaseGexTransport):
|
||||
|
||||
def write(self, buffer):
|
||||
""" Send a buffer of bytes """
|
||||
self._dev.write(0x02, buffer, 100)
|
||||
self._dev.write(0x04, buffer, 100)
|
||||
|
||||
def poll(self, timeout, testfunc=None):
|
||||
# Using time.sleep() would block for too long. Instead we release the semaphore on each Rx chunk of data
|
||||
|
||||
+2
-2
@@ -11,10 +11,10 @@ with gex.Client(gex.TrxRawUSB()) as client:
|
||||
adc = gex.ADC(client, 'a')
|
||||
|
||||
adc.set_active_channels([3])
|
||||
rate=44000
|
||||
rate=20000
|
||||
fs = adc.set_sample_rate(rate)
|
||||
|
||||
count = 44000*2
|
||||
count = 1000
|
||||
data = np.add(adc.capture(count) / 4096, -0.5)
|
||||
|
||||
if data is not None:
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#!/bin/env python3
|
||||
import time
|
||||
|
||||
import gex
|
||||
|
||||
with gex.Client(gex.TrxRawUSB()) as client:
|
||||
time.sleep(3)
|
||||
print("End")
|
||||
|
||||
Reference in New Issue
Block a user