From: Uwe Hermann Date: Tue, 10 Jan 2012 20:10:23 +0000 (+0100) Subject: srd: Use 'import sigrokdecode as srd' for brevity. X-Git-Tag: libsigrokdecode-0.1.0~178 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=677d597b072c0a1d2df81c5c193cd3678aef8d03;p=libsigrokdecode.git srd: Use 'import sigrokdecode as srd' for brevity. --- diff --git a/decoders/ddc.py b/decoders/ddc.py index b4681d0..a628565 100644 --- a/decoders/ddc.py +++ b/decoders/ddc.py @@ -24,10 +24,10 @@ # and a display device. The stream is output as plain bytes. # -import sigrokdecode +import sigrokdecode as srd -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'ddc' name = 'DDC' longname = 'Display Data Channel' @@ -45,7 +45,7 @@ class Decoder(sigrokdecode.Decoder): self.state = None def start(self, metadata): - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'ddc') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'ddc') def decode(self, start_sample, end_sample, i2c_data): try: diff --git a/decoders/i2c.py b/decoders/i2c.py index b101e8a..6982798 100644 --- a/decoders/i2c.py +++ b/decoders/i2c.py @@ -93,7 +93,7 @@ # # -import sigrokdecode +import sigrokdecode as srd # annotation feed formats ANN_SHIFTED = 0 @@ -119,7 +119,7 @@ FIND_ADDRESS = 1 FIND_DATA = 2 -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'i2c' name = 'I2C' longname = 'Inter-Integrated Circuit (I2C) bus' @@ -162,8 +162,8 @@ class Decoder(sigrokdecode.Decoder): self.oldsda = None def start(self, metadata): - self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'i2c') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'i2c') + self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'i2c') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'i2c') def report(self): pass diff --git a/decoders/mx25lxx05d.py b/decoders/mx25lxx05d.py index bd1ce16..72e1e1b 100644 --- a/decoders/mx25lxx05d.py +++ b/decoders/mx25lxx05d.py @@ -30,7 +30,7 @@ # http://www.macronix.com/QuickPlace/hq/PageLibrary4825740B00298A3B.nsf/h_Index/3F21BAC2E121E17848257639003A3146/$File/MX25L1605D-3205D-6405D-1.5.pdf # -import sigrokdecode +import sigrokdecode as srd # States IDLE = -1 @@ -157,7 +157,7 @@ miso_packets = [ {'type': 'D', 'range': (10, 11), 'data': 0xff, 'ann': ''}, ] -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'mx25lxx05d' name = 'Macronix MX25Lxx05D' longname = 'Macronix MX25Lxx05D SPI flash chip decoder' @@ -179,8 +179,8 @@ class Decoder(sigrokdecode.Decoder): self.out = [] def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'mx25lxx05d') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'mx25lxx05d') + # self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'mx25lxx05d') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'mx25lxx05d') def report(self): pass diff --git a/decoders/nunchuk.py b/decoders/nunchuk.py index cd2c064..009459d 100644 --- a/decoders/nunchuk.py +++ b/decoders/nunchuk.py @@ -30,7 +30,7 @@ # https://www.sparkfun.com/products/9281 # -import sigrokdecode +import sigrokdecode as srd # States IDLE = 0 @@ -62,7 +62,7 @@ example_packets = [ {'type': 'P', 'range': (32, 33), 'data': None, 'ann': ''}, ] -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'nunchuk' name = 'Nunchuk' longname = 'Nintendo Wii Nunchuk decoder' @@ -87,8 +87,8 @@ class Decoder(sigrokdecode.Decoder): self.databytecount = 0 def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'nunchuk') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'nunchuk') + # self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'nunchuk') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'nunchuk') def report(self): pass diff --git a/decoders/pan1321.py b/decoders/pan1321.py index bebfc68..441cba0 100644 --- a/decoders/pan1321.py +++ b/decoders/pan1321.py @@ -22,7 +22,7 @@ # TODO # -import sigrokdecode +import sigrokdecode as srd # Annotation feed formats ANN_ASCII = 0 @@ -30,7 +30,7 @@ ANN_ASCII = 0 # UART 'data' packet type. T_DATA = 1 -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'pan1321' name = 'Panasonic PAN1321' longname = 'TODO.' @@ -56,8 +56,8 @@ class Decoder(sigrokdecode.Decoder): self.cmd = '' def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'pan1321') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'pan1321') + # self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'pan1321') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'pan1321') def report(self): pass diff --git a/decoders/spi.py b/decoders/spi.py index a866767..5529025 100644 --- a/decoders/spi.py +++ b/decoders/spi.py @@ -18,9 +18,9 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -import sigrokdecode +import sigrokdecode as srd -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'spi' name = 'SPI' desc = '...desc...' @@ -46,8 +46,8 @@ class Decoder(sigrokdecode.Decoder): self.out_ann = None def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'spi') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'spi') + # self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'spi') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'spi') def report(self): return 'SPI: %d bytes received' % self.bytesreceived diff --git a/decoders/srd_usb.py b/decoders/srd_usb.py index c97ef73..842cf03 100644 --- a/decoders/srd_usb.py +++ b/decoders/srd_usb.py @@ -40,7 +40,7 @@ # http://www.usb.org/developers/docs/ # -import sigrokdecode +import sigrokdecode as srd # States SE0, J, K, SE1 = 0, 1, 2, 3 @@ -99,7 +99,7 @@ def packet_decode(packet): return pid + ' ' + data -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'usb' name = 'USB' desc = 'Universal Serial Bus' @@ -123,8 +123,8 @@ class Decoder(sigrokdecode.Decoder): def start(self, metadata): self.rate = metadata['samplerate'] - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'usb') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'usb') + # self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'usb') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'usb') if self.rate < 48000000: raise Exception("Sample rate not sufficient for USB decoding") # Initialise decoder state. diff --git a/decoders/transitioncounter.py b/decoders/transitioncounter.py index 9d437d1..eaf8738 100644 --- a/decoders/transitioncounter.py +++ b/decoders/transitioncounter.py @@ -18,9 +18,9 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -import sigrokdecode +import sigrokdecode as srd -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'transitioncounter' name = 'Transition counter' longname = '...' @@ -42,8 +42,8 @@ class Decoder(sigrokdecode.Decoder): self.lastsample = None def start(self, metadata): - # self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'transitioncounter') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'transitioncounter') + # self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'transitioncounter') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'transitioncounter') def report(self): pass diff --git a/decoders/uart.py b/decoders/uart.py index c9f7875..c3a90ef 100644 --- a/decoders/uart.py +++ b/decoders/uart.py @@ -125,7 +125,7 @@ # [T_PARITY_ERROR, (0, 1)] # -import sigrokdecode +import sigrokdecode as srd # States WAIT_FOR_START_BIT = 0 @@ -190,7 +190,7 @@ def parity_ok(parity_type, parity_bit, data, num_data_bits): else: raise Exception('Invalid parity type: %d' % parity_type) -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'uart' name = 'UART' longname = 'Universal Asynchronous Receiver/Transmitter (UART)' @@ -258,8 +258,8 @@ class Decoder(sigrokdecode.Decoder): def start(self, metadata): self.samplerate = metadata['samplerate'] - self.out_proto = self.add(sigrokdecode.SRD_OUTPUT_PROTO, 'uart') - self.out_ann = self.add(sigrokdecode.SRD_OUTPUT_ANN, 'uart') + self.out_proto = self.add(srd.SRD_OUTPUT_PROTO, 'uart') + self.out_ann = self.add(srd.SRD_OUTPUT_ANN, 'uart') # TODO ### self.baudrate = metadata['baudrate']