}
VDM_ACK = ['REQ', 'ACK', 'NAK', 'BSY']
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'usb_power_delivery'
self.putwarn('No start of packet found', 'XXX')
return -1 # No Start Of Packet
- def __init__(self, **kwargs):
+ def __init__(self):
self.samplerate = None
self.idx = 0
self.packet_seq = 0
)
def us2samples(self, us):
- if not self.samplerate:
- raise Exception('Need the samplerate.')
return int(us * self.samplerate / 1000000)
def decode_packet(self):
bitrate = self.samplerate*len(self.bits) / float(es - ss)
self.put(es, ss, self.out_bitrate, int(bitrate))
# Raw binary data (BMC decoded)
- self.put(es, ss, self.out_binary, (0, bytes(self.bits)))
+ self.put(es, ss, self.out_binary, [0, bytes(self.bits)])
def decode(self, ss, es, data):
if not self.samplerate:
- raise Exception('Cannot decode without samplerate.')
+ raise SamplerateError('Cannot decode without samplerate.')
for (self.samplenum, pins) in data:
# find edges ...
if self.oldpins == pins: