From: Uwe Hermann Date: Tue, 15 Jul 2014 20:49:43 +0000 (+0200) Subject: All PDs: Minor whitespace and consistency fixes. X-Git-Tag: libsigrokdecode-0.4.0~204 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=35b380b1156434b73d4a976c68f5ab3604c8510a;p=libsigrokdecode.git All PDs: Minor whitespace and consistency fixes. - No newlines at the end of files. - No trailing ';' characters. - Comparison with None: Use 'is None' or 'is not None'. - Comparison with True/False: Use 'if cond:' or 'if not cond:'. - Various minor whitespace fixes. --- diff --git a/decoders/avr_isp/__init__.py b/decoders/avr_isp/__init__.py index 4c4a900..87a6e7c 100644 --- a/decoders/avr_isp/__init__.py +++ b/decoders/avr_isp/__init__.py @@ -24,4 +24,3 @@ Programming (ISP) protocol of some Atmel AVR 8-bit microcontrollers. ''' from .pd import * - diff --git a/decoders/avr_isp/parts.py b/decoders/avr_isp/parts.py index b9747f8..8e437b9 100644 --- a/decoders/avr_isp/parts.py +++ b/decoders/avr_isp/parts.py @@ -40,4 +40,3 @@ part = { (0x01, 0x02): 'Device locked', # TODO: Lots more entries. } - diff --git a/decoders/avr_isp/pd.py b/decoders/avr_isp/pd.py index a6b9c80..3a7c868 100644 --- a/decoders/avr_isp/pd.py +++ b/decoders/avr_isp/pd.py @@ -208,4 +208,3 @@ class Decoder(srd.Decoder): self.mosi_bytes = [] self.miso_bytes = [] - diff --git a/decoders/can/__init__.py b/decoders/can/__init__.py index 38731c2..9f9fcde 100644 --- a/decoders/can/__init__.py +++ b/decoders/can/__init__.py @@ -28,4 +28,3 @@ MCP-2515DM-BM). ''' from .pd import * - diff --git a/decoders/can/pd.py b/decoders/can/pd.py index f80ebc6..df2cbee 100644 --- a/decoders/can/pd.py +++ b/decoders/can/pd.py @@ -379,4 +379,3 @@ class Decoder(srd.Decoder): if not self.reached_bit(self.curbit): continue self.handle_bit(can_rx) - diff --git a/decoders/dcf77/__init__.py b/decoders/dcf77/__init__.py index 04805c2..1a29462 100644 --- a/decoders/dcf77/__init__.py +++ b/decoders/dcf77/__init__.py @@ -27,4 +27,3 @@ http://en.wikipedia.org/wiki/DCF77 ''' from .pd import * - diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py index 14d8637..adee403 100644 --- a/decoders/dcf77/pd.py +++ b/decoders/dcf77/pd.py @@ -242,7 +242,7 @@ class Decoder(srd.Decoder): # Even parity over date bits (36-58): DCF77 bit 58. parity = self.datebits.count(1) s = 'OK' if ((parity % 2) == 0) else 'INVALID!' - self.putx([16, ['Date parity: %s' % s, 'DP: %s' %s]]) + self.putx([16, ['Date parity: %s' % s, 'DP: %s' % s]]) self.datebits = [] else: raise Exception('Invalid DCF77 bit: %d' % c) @@ -314,4 +314,3 @@ class Decoder(srd.Decoder): self.state = 'WAIT FOR RISING EDGE' self.oldval = val - diff --git a/decoders/ds1307/__init__.py b/decoders/ds1307/__init__.py index 5bc28c3..70980a6 100644 --- a/decoders/ds1307/__init__.py +++ b/decoders/ds1307/__init__.py @@ -24,4 +24,3 @@ real-time clock (RTC) specific registers and commands. ''' from .pd import * - diff --git a/decoders/ds1307/pd.py b/decoders/ds1307/pd.py index 1a49f9a..77effbf 100644 --- a/decoders/ds1307/pd.py +++ b/decoders/ds1307/pd.py @@ -1,6 +1,6 @@ ## ## This file is part of the libsigrokdecode project. -## +## ## Copyright (C) 2012 Uwe Hermann ## Copyright (C) 2013 Matt Ranostay ## @@ -81,7 +81,7 @@ class Decoder(srd.Decoder): self.putx([0, ['Day of Week: %s' % days_of_week[self.days - 1]]]) def handle_reg_0x04(self, b): # Date - self.date = bcd2int(b & 0x3f) + self.date = bcd2int(b & 0x3f) self.putx([0, ['Days: %d' % self.date]]) def handle_reg_0x05(self, b): # Month @@ -89,7 +89,7 @@ class Decoder(srd.Decoder): self.putx([0, ['Months: %d' % self.months]]) def handle_reg_0x06(self, b): # Year - self.years = bcd2int(b & 0xff) + 2000; + self.years = bcd2int(b & 0xff) + 2000 self.putx([0, ['Years: %d' % self.years]]) def handle_reg_0x07(self, b): # Control Register @@ -164,4 +164,3 @@ class Decoder(srd.Decoder): self.state = 'IDLE' else: pass # TODO? - diff --git a/decoders/edid/__init__.py b/decoders/edid/__init__.py index 8683006..318130f 100644 --- a/decoders/edid/__init__.py +++ b/decoders/edid/__init__.py @@ -37,4 +37,3 @@ More information on EDID is available here: ''' from .pd import * - diff --git a/decoders/edid/pd.py b/decoders/edid/pd.py index 8af10ae..e655fdd 100644 --- a/decoders/edid/pd.py +++ b/decoders/edid/pd.py @@ -465,4 +465,3 @@ class Decoder(srd.Decoder): else: if self.cache[i+2] == 0 or self.cache[i+4] == 0: self.decode_descriptor(i) - diff --git a/decoders/guess_bitrate/__init__.py b/decoders/guess_bitrate/__init__.py index 9c7e6a4..1b41f72 100644 --- a/decoders/guess_bitrate/__init__.py +++ b/decoders/guess_bitrate/__init__.py @@ -35,4 +35,3 @@ the expected bitrate/baudrate that might be used on the channel. ''' from .pd import * - diff --git a/decoders/guess_bitrate/pd.py b/decoders/guess_bitrate/pd.py index 1d7434b..250d519 100644 --- a/decoders/guess_bitrate/pd.py +++ b/decoders/guess_bitrate/pd.py @@ -53,7 +53,7 @@ class Decoder(srd.Decoder): def metadata(self, key, value): if key == srd.SRD_CONF_SAMPLERATE: - self.samplerate = value; + self.samplerate = value def decode(self, ss, es, data): if not self.samplerate: @@ -67,22 +67,21 @@ class Decoder(srd.Decoder): continue # Initialize first self.olddata with the first sample value. - if self.olddata == None: + if self.olddata is None: self.olddata = data continue # Get the smallest distance between two transitions # and use that to calculate the bitrate/baudrate. - if self.first_transition == True: + if self.first_transition: self.ss_edge = self.samplenum self.first_transition = False else: b = self.samplenum - self.ss_edge - if self.bitwidth == None or b < self.bitwidth: + if self.bitwidth is None or b < self.bitwidth: self.bitwidth = b bitrate = int(float(self.samplerate) / float(b)) self.putx([0, ['%d' % bitrate]]) self.ss_edge = self.samplenum self.olddata = data - diff --git a/decoders/i2c/__init__.py b/decoders/i2c/__init__.py index ba40245..eaebbdb 100644 --- a/decoders/i2c/__init__.py +++ b/decoders/i2c/__init__.py @@ -24,4 +24,3 @@ bus using two signals (SCL = serial clock line, SDA = serial data line). ''' from .pd import * - diff --git a/decoders/i2c/pd.py b/decoders/i2c/pd.py index b46fd1d..0408c7d 100644 --- a/decoders/i2c/pd.py +++ b/decoders/i2c/pd.py @@ -299,4 +299,3 @@ class Decoder(srd.Decoder): # Save current SDA/SCL values for the next round. self.oldscl, self.oldsda = scl, sda - diff --git a/decoders/i2cdemux/__init__.py b/decoders/i2cdemux/__init__.py index c5202c5..265e568 100644 --- a/decoders/i2cdemux/__init__.py +++ b/decoders/i2cdemux/__init__.py @@ -26,4 +26,3 @@ stream containing only I²C packets for one specific I²C slave. ''' from .pd import * - diff --git a/decoders/i2cdemux/pd.py b/decoders/i2cdemux/pd.py index e5cf47a..68b75a0 100644 --- a/decoders/i2cdemux/pd.py +++ b/decoders/i2cdemux/pd.py @@ -75,4 +75,3 @@ class Decoder(srd.Decoder): self.stream = -1 else: pass # Do nothing, only add the I²C packet to our cache. - diff --git a/decoders/i2cfilter/__init__.py b/decoders/i2cfilter/__init__.py index 6cbab8a..ddb16ff 100644 --- a/decoders/i2cfilter/__init__.py +++ b/decoders/i2cfilter/__init__.py @@ -35,4 +35,3 @@ of the I²C session will be output. ''' from .pd import * - diff --git a/decoders/i2cfilter/pd.py b/decoders/i2cfilter/pd.py index 1a9f433..3c02a2e 100644 --- a/decoders/i2cfilter/pd.py +++ b/decoders/i2cfilter/pd.py @@ -87,4 +87,3 @@ class Decoder(srd.Decoder): self.packets = [] else: pass # Do nothing, only add the I²C packet to our cache. - diff --git a/decoders/i2s/__init__.py b/decoders/i2s/__init__.py index b9c0ed7..550a8c8 100644 --- a/decoders/i2s/__init__.py +++ b/decoders/i2s/__init__.py @@ -28,4 +28,3 @@ http://en.wikipedia.org/wiki/I2s ''' from .pd import * - diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py index dc42a4e..8b45a75 100644 --- a/decoders/i2s/pd.py +++ b/decoders/i2s/pd.py @@ -93,8 +93,8 @@ class Decoder(srd.Decoder): # Calculate the sample rate. samplerate = '?' - if self.start_sample != None and \ - self.first_sample != None and \ + if self.start_sample is not None and \ + self.first_sample is not None and \ self.start_sample > self.first_sample: samplerate = '%d' % (self.samplesreceived * self.samplerate / (self.start_sample - @@ -151,7 +151,7 @@ class Decoder(srd.Decoder): continue # Only submit the sample, if we received the beginning of it. - if self.start_sample != None: + if self.start_sample is not None: if not self.wrote_wav_header: self.put(0, 0, self.out_bin, (0, self.wav_header())) @@ -182,8 +182,7 @@ class Decoder(srd.Decoder): self.start_sample = self.samplenum # Save the first sample position. - if self.first_sample == None: + if self.first_sample is None: self.first_sample = self.samplenum self.oldws = ws - diff --git a/decoders/ir_nec/__init__.py b/decoders/ir_nec/__init__.py index 84bf428..0765668 100644 --- a/decoders/ir_nec/__init__.py +++ b/decoders/ir_nec/__init__.py @@ -23,4 +23,3 @@ NEC is a pulse-distance based infrared remote control protocol. ''' from .pd import * - diff --git a/decoders/ir_nec/lists.py b/decoders/ir_nec/lists.py index c9dc595..3f730d9 100644 --- a/decoders/ir_nec/lists.py +++ b/decoders/ir_nec/lists.py @@ -49,4 +49,3 @@ command = { 68: ['AV', 'AV'], }.items())), } - diff --git a/decoders/ir_nec/pd.py b/decoders/ir_nec/pd.py index ce2e9f2..d14c7d3 100644 --- a/decoders/ir_nec/pd.py +++ b/decoders/ir_nec/pd.py @@ -204,4 +204,3 @@ class Decoder(srd.Decoder): self.state = 'IDLE' self.old_ir = self.ir - diff --git a/decoders/ir_rc5/__init__.py b/decoders/ir_rc5/__init__.py index 085082f..d94824d 100644 --- a/decoders/ir_rc5/__init__.py +++ b/decoders/ir_rc5/__init__.py @@ -23,4 +23,3 @@ RC-5 is a biphase/manchester based infrared remote control protocol. ''' from .pd import * - diff --git a/decoders/ir_rc5/lists.py b/decoders/ir_rc5/lists.py index 8a81ef7..2ac227e 100644 --- a/decoders/ir_rc5/lists.py +++ b/decoders/ir_rc5/lists.py @@ -92,4 +92,3 @@ command = { 55: ['Recording', 'Rec'], }.items())), } - diff --git a/decoders/ir_rc5/pd.py b/decoders/ir_rc5/pd.py index bd99826..4926cb6 100644 --- a/decoders/ir_rc5/pd.py +++ b/decoders/ir_rc5/pd.py @@ -173,7 +173,7 @@ class Decoder(srd.Decoder): bit = 0 if edge == 's' else None self.edges.append(self.samplenum) - if bit != None: + if bit is not None: self.bits.append([self.samplenum, bit]) if len(self.bits) == 14: @@ -181,4 +181,3 @@ class Decoder(srd.Decoder): self.reset_decoder_state() self.old_ir = self.ir - diff --git a/decoders/jtag/__init__.py b/decoders/jtag/__init__.py index 047e54a..0caf5aa 100644 --- a/decoders/jtag/__init__.py +++ b/decoders/jtag/__init__.py @@ -29,4 +29,3 @@ http://focus.ti.com/lit/an/ssya002c/ssya002c.pdf ''' from .pd import * - diff --git a/decoders/jtag/pd.py b/decoders/jtag/pd.py index d7b35aa..49077ed 100644 --- a/decoders/jtag/pd.py +++ b/decoders/jtag/pd.py @@ -143,7 +143,7 @@ class Decoder(srd.Decoder): # Rising TCK edges always advance the state machine. self.advance_state_machine(tms) - if self.first == True: + if self.first: # Save the start sample and item for later (no output yet). self.ss_item = self.samplenum self.first = False @@ -214,4 +214,3 @@ class Decoder(srd.Decoder): self.handle_rising_tck_edge(tdi, tdo, tck, tms) self.oldtck = tck - diff --git a/decoders/jtag_stm32/__init__.py b/decoders/jtag_stm32/__init__.py index 8a28528..2b091fb 100644 --- a/decoders/jtag_stm32/__init__.py +++ b/decoders/jtag_stm32/__init__.py @@ -28,4 +28,3 @@ http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/REFERENC ''' from .pd import * - diff --git a/decoders/jtag_stm32/pd.py b/decoders/jtag_stm32/pd.py index 9113b4c..f2dd3c7 100644 --- a/decoders/jtag_stm32/pd.py +++ b/decoders/jtag_stm32/pd.py @@ -218,4 +218,3 @@ class Decoder(srd.Decoder): handle_reg(cmd, val) if cmd == 'DR TDO': # TODO: Assumes 'DR TDI' comes before 'DR TDO' self.state = 'IDLE' - diff --git a/decoders/lm75/__init__.py b/decoders/lm75/__init__.py index d096418..4105814 100644 --- a/decoders/lm75/__init__.py +++ b/decoders/lm75/__init__.py @@ -24,4 +24,3 @@ This decoder stacks on top of the 'i2c' PD and decodes the National LM75 ''' from .pd import * - diff --git a/decoders/lm75/pd.py b/decoders/lm75/pd.py index 6655ef0..9483940 100644 --- a/decoders/lm75/pd.py +++ b/decoders/lm75/pd.py @@ -181,4 +181,3 @@ class Decoder(srd.Decoder): else: # self.putx([0, ['Ignoring: %s (data=%s)' % (cmd, databyte)]]) pass - diff --git a/decoders/lpc/__init__.py b/decoders/lpc/__init__.py index 62a4307..986b550 100644 --- a/decoders/lpc/__init__.py +++ b/decoders/lpc/__init__.py @@ -24,4 +24,3 @@ some PC mainboards, such as the "BIOS chip" or the so-called "Super I/O". ''' from .pd import * - diff --git a/decoders/lpc/pd.py b/decoders/lpc/pd.py index b626e0d..5e25db4 100644 --- a/decoders/lpc/pd.py +++ b/decoders/lpc/pd.py @@ -346,7 +346,7 @@ class Decoder(srd.Decoder): if self.state == 'IDLE': # A valid LPC cycle starts with LFRAME# being asserted (low). if lframe != 0: - continue + continue self.ss_block = self.samplenum self.state = 'GET START' self.lad = -1 @@ -365,4 +365,3 @@ class Decoder(srd.Decoder): self.handle_get_data(lad, lad_bits) elif self.state == 'GET TAR2': self.handle_get_tar2(lad, lad_bits) - diff --git a/decoders/maxim_ds28ea00/__init__.py b/decoders/maxim_ds28ea00/__init__.py index 34d1d08..750d699 100644 --- a/decoders/maxim_ds28ea00/__init__.py +++ b/decoders/maxim_ds28ea00/__init__.py @@ -24,4 +24,3 @@ Maxim DS28EA00 1-Wire digital thermometer protocol. ''' from .pd import * - diff --git a/decoders/maxim_ds28ea00/pd.py b/decoders/maxim_ds28ea00/pd.py index 1e2c36a..229331f 100644 --- a/decoders/maxim_ds28ea00/pd.py +++ b/decoders/maxim_ds28ea00/pd.py @@ -88,4 +88,3 @@ class Decoder(srd.Decoder): self.putx([0, ['Temperature conversion status: 0x%02x' % val]]) elif self.state in [s.upper() for s in command.values()]: self.putx([0, ['TODO \'%s\': 0x%02x' % (self.state, val)]]) - diff --git a/decoders/midi/__init__.py b/decoders/midi/__init__.py index a453346..19be493 100644 --- a/decoders/midi/__init__.py +++ b/decoders/midi/__init__.py @@ -27,4 +27,3 @@ baud rate of 31250 baud (+/- 1%) and 8n1 settings. Bytes are sent LSB-first. ''' from .pd import * - diff --git a/decoders/midi/lists.py b/decoders/midi/lists.py index bc0f9b8..c72f5c9 100644 --- a/decoders/midi/lists.py +++ b/decoders/midi/lists.py @@ -267,7 +267,7 @@ sysex_manufacturer_ids = { (0x00, 0x00, 0x5c): 'AT&T Bell Labs', (0x00, 0x00, 0x5e): 'Symetrix', (0x00, 0x00, 0x5f): 'MIDI the World', - + (0x00, 0x00, 0x60): 'Desper Products', (0x00, 0x00, 0x61): 'Micros\'N MIDI', (0x00, 0x00, 0x62): 'Accordians Intl', @@ -467,4 +467,3 @@ control_functions = { 0x7e: 'poly mode off', # mono mode on, all notes off 0x7f: 'poly mode on', # mono mode off, all notes off } - diff --git a/decoders/midi/pd.py b/decoders/midi/pd.py index 0717dbc..68a8369 100644 --- a/decoders/midi/pd.py +++ b/decoders/midi/pd.py @@ -206,4 +206,3 @@ class Decoder(srd.Decoder): self.handle_syscommon_msg(pdata) elif self.state == 'HANDLE SYSREALTIME MSG': self.handle_sysrealtime_msg(pdata) - diff --git a/decoders/mlx90614/__init__.py b/decoders/mlx90614/__init__.py index 29cb2a9..1814ac9 100644 --- a/decoders/mlx90614/__init__.py +++ b/decoders/mlx90614/__init__.py @@ -24,4 +24,3 @@ infrared thermometer protocol. ''' from .pd import * - diff --git a/decoders/mlx90614/pd.py b/decoders/mlx90614/pd.py index eeb2743..aa1ead5 100644 --- a/decoders/mlx90614/pd.py +++ b/decoders/mlx90614/pd.py @@ -73,4 +73,3 @@ class Decoder(srd.Decoder): self.putx([1, ['Temperature: %3.2f K' % kelvin]]) self.state = 'IGNORE START REPEAT' self.data = [] - diff --git a/decoders/mx25lxx05d/__init__.py b/decoders/mx25lxx05d/__init__.py index 71d7b3c..85d3434 100644 --- a/decoders/mx25lxx05d/__init__.py +++ b/decoders/mx25lxx05d/__init__.py @@ -29,4 +29,3 @@ http://www.macronix.com/QuickPlace/hq/PageLibrary4825740B00298A3B.nsf/h_Index/3F ''' from .pd import * - diff --git a/decoders/mx25lxx05d/pd.py b/decoders/mx25lxx05d/pd.py index a6c72d8..2222c37 100644 --- a/decoders/mx25lxx05d/pd.py +++ b/decoders/mx25lxx05d/pd.py @@ -360,7 +360,7 @@ class Decoder(srd.Decoder): self.ss, self.es = ss, es # If we encountered a known chip command, enter the resp. state. - if self.state == None: + if self.state is None: self.state = mosi self.cmdstate = 1 @@ -372,4 +372,3 @@ class Decoder(srd.Decoder): else: self.putx([24, ['Unknown command: 0x%02x' % mosi]]) self.state = None - diff --git a/decoders/mxc6225xu/__init__.py b/decoders/mxc6225xu/__init__.py index c4209c8..c522711 100644 --- a/decoders/mxc6225xu/__init__.py +++ b/decoders/mxc6225xu/__init__.py @@ -27,4 +27,3 @@ Its I²C slave address is 0x2a. ''' from .pd import * - diff --git a/decoders/mxc6225xu/pd.py b/decoders/mxc6225xu/pd.py index c506fb6..2f09488 100644 --- a/decoders/mxc6225xu/pd.py +++ b/decoders/mxc6225xu/pd.py @@ -213,4 +213,3 @@ class Decoder(srd.Decoder): self.state = 'IDLE' else: pass # TODO? - diff --git a/decoders/nrf24l01/pd.py b/decoders/nrf24l01/pd.py index 39a6808..3208a20 100644 --- a/decoders/nrf24l01/pd.py +++ b/decoders/nrf24l01/pd.py @@ -50,26 +50,26 @@ regs = { 0x16: ('RX_PW_P5', 1), 0x17: ('FIFO_STATUS', 1), 0x1c: ('DYNPD', 1), - 0x1d: ('FEATURE', 1) + 0x1d: ('FEATURE', 1), } class Decoder(srd.Decoder): api_version = 2 id = 'nrf24l01' - name = 'NRF24L01(+)' + name = 'nRF24L01(+)' longname = 'Nordic Semiconductor nRF24L01/nRF24L01+' - desc = '2.4 GHz transceiver chip.' + desc = '2.4GHz transceiver chip.' license = 'gplv2+' inputs = ['spi'] outputs = ['nrf24l01'] annotations = ( - # sent from the host to the chip - ('cmd', 'Commands send to the device.'), - ('tx-data', 'Payload send to the device.'), + # Sent from the host to the chip. + ('cmd', 'Commands sent to the device'), + ('tx-data', 'Payload sent to the device'), - # returned by the chip - ('register', 'Registers read from the device.'), - ('rx-data', 'Payload read from the device.'), + # Returned by the chip. + ('register', 'Registers read from the device'), + ('rx-data', 'Payload read from the device'), ('warning', 'Warnings'), ) @@ -100,17 +100,17 @@ class Decoder(srd.Decoder): def next(self): '''Resets the decoder after a complete command was decoded.''' - # 'True' for the first byte after CS went low + # 'True' for the first byte after CS went low. self.first = True - # the current command, and the minimum and maximum number - # of data bytes to follow + # The current command, and the minimum and maximum number + # of data bytes to follow. self.cmd = None self.min = 0 self.max = 0 - # used to collect the bytes after the command byte - # (and the start/end sample number) + # Used to collect the bytes after the command byte + # (and the start/end sample number). self.mb = [] self.mb_s = -1 self.mb_e = -1 @@ -127,15 +127,15 @@ class Decoder(srd.Decoder): '''Decodes the command byte 'b' at position 'pos' and prepares the decoding of the following data bytes.''' c = self.parse_command(b) - if c == None: + if c is None: self.warn(pos, 'unknown command') return self.cmd, self.dat, self.min, self.max = c if self.cmd in ('W_REGISTER', 'ACTIVATE'): - # don't output anything now, the command is merged with - # the data bytes following it + # Don't output anything now, the command is merged with + # the data bytes following it. self.mb_s = pos[0] else: self.putp(pos, self.ann_cmd, self.format_command()) @@ -196,20 +196,19 @@ class Decoder(srd.Decoder): ''' if type(regid) == int: - # get the name of the register + # Get the name of the register. if regid not in regs: self.warn(pos, 'unknown register') return - name = regs[regid][0] else: name = regid - # multi byte register come LSByte first + # Multi byte register come LSByte first. data = reversed(data) if self.cmd == 'W_REGISTER' and ann == self.ann_cmd: - # the 'W_REGISTER' command is merged with the following byte(s) + # The 'W_REGISTER' command is merged with the following byte(s). label = '{}: {}'.format(self.format_command(), name) else: label = 'Reg. {}'.format(name) @@ -236,10 +235,10 @@ class Decoder(srd.Decoder): if self.cmd == 'R_REGISTER': self.decode_register(pos, self.ann_reg, - self.dat, self.miso_bytes()); + self.dat, self.miso_bytes()) elif self.cmd == 'W_REGISTER': self.decode_register(pos, self.ann_cmd, - self.dat, self.mosi_bytes()); + self.dat, self.mosi_bytes()) elif self.cmd == 'R_RX_PAYLOAD': self.decode_mb_data(pos, self.ann_rx, self.miso_bytes(), 'RX payload', False) @@ -264,11 +263,11 @@ class Decoder(srd.Decoder): if ptype == 'CS-CHANGE': if data1 == 0 and data2 == 1: - # rising edge, the complete command is transmitted, process - # the bytes that were send after the command byte + # Rising edge, the complete command is transmitted, process + # the bytes that were send after the command byte. if self.cmd: - # check if we got the minimum number of data bytes - # after the command byte + # Check if we got the minimum number of data bytes + # after the command byte. if len(self.mb) < self.min: self.warn((ss, ss), 'missing data bytes') elif self.mb: @@ -276,24 +275,23 @@ class Decoder(srd.Decoder): self.next() elif ptype == 'DATA': - mosi = data1 - miso = data2 + mosi, miso = data1, data2 pos = (ss, es) - if miso == None or mosi == None: + if miso is None or mosi is None: raise MissingDataError('Both MISO and MOSI pins required.') if self.first: self.first = False - # first MOSI byte is always the command + # First MOSI byte is always the command. self.decode_command(pos, mosi) - # first MISO byte is always the status register + # First MISO byte is always the status register. self.decode_register(pos, self.ann_reg, 'STATUS', [miso]) else: if not self.cmd or len(self.mb) >= self.max: self.warn(pos, 'excess byte') else: - # collect the bytes after the command byte + # Collect the bytes after the command byte. if self.mb_s == -1: self.mb_s = ss self.mb_e = es diff --git a/decoders/nunchuk/__init__.py b/decoders/nunchuk/__init__.py index 2fdaaeb..ef6a74a 100644 --- a/decoders/nunchuk/__init__.py +++ b/decoders/nunchuk/__init__.py @@ -29,4 +29,3 @@ https://www.sparkfun.com/products/9281 ''' from .pd import * - diff --git a/decoders/nunchuk/pd.py b/decoders/nunchuk/pd.py index 8ed98e6..ef3d267 100644 --- a/decoders/nunchuk/pd.py +++ b/decoders/nunchuk/pd.py @@ -202,4 +202,3 @@ class Decoder(srd.Decoder): else: # self.putx([14, ['Ignoring: %s (data=%s)' % (cmd, databyte)]]) pass - diff --git a/decoders/onewire_link/__init__.py b/decoders/onewire_link/__init__.py index d153f93..6248916 100644 --- a/decoders/onewire_link/__init__.py +++ b/decoders/onewire_link/__init__.py @@ -66,4 +66,3 @@ read the decoder source code to understand them correctly. ''' from .pd import * - diff --git a/decoders/onewire_link/pd.py b/decoders/onewire_link/pd.py index c8d6cd7..2d4e089 100644 --- a/decoders/onewire_link/pd.py +++ b/decoders/onewire_link/pd.py @@ -185,7 +185,7 @@ class Decoder(srd.Decoder): if (time_min < 0.0000073) or (time_max > 0.000010): self.putm([1, ['The overdrive mode presence sample time interval ' + '(%2.1fus-%2.1fus) should be inside (7.3us, 10.0us).' - % (time_min*1000000, time_max*1000000)]]) + % (time_min * 1000000, time_max * 1000000)]]) def decode(self, ss, es, data): if not self.samplerate: diff --git a/decoders/onewire_network/__init__.py b/decoders/onewire_network/__init__.py index 31e9134..1d584ef 100644 --- a/decoders/onewire_network/__init__.py +++ b/decoders/onewire_network/__init__.py @@ -55,4 +55,3 @@ TODO: ''' from .pd import * - diff --git a/decoders/pan1321/__init__.py b/decoders/pan1321/__init__.py index 9bda523..7aa20f0 100644 --- a/decoders/pan1321/__init__.py +++ b/decoders/pan1321/__init__.py @@ -24,4 +24,3 @@ Bluetooth module Serial Port Profile (SPP) protocol. ''' from .pd import * - diff --git a/decoders/pan1321/pd.py b/decoders/pan1321/pd.py index 7edd1c8..60e7549 100644 --- a/decoders/pan1321/pd.py +++ b/decoders/pan1321/pd.py @@ -156,4 +156,3 @@ class Decoder(srd.Decoder): self.handle_host_command(rxtx, self.cmd[rxtx][:-2]) self.cmd[rxtx] = '' - diff --git a/decoders/parallel/__init__.py b/decoders/parallel/__init__.py index cc1f3d1..ee8b444 100644 --- a/decoders/parallel/__init__.py +++ b/decoders/parallel/__init__.py @@ -33,4 +33,3 @@ For an 8-bit bus you should use D0-D7, for a 16-bit bus use D0-D15 and so on. ''' from .pd import * - diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py index 0b512c8..a695ca6 100644 --- a/decoders/parallel/pd.py +++ b/decoders/parallel/pd.py @@ -122,7 +122,7 @@ class Decoder(srd.Decoder): self.items.append(item) self.itemcount += 1 - if self.first == True: + if self.first: # Save the start sample and item for later (no output yet). self.ss_item = self.samplenum self.first = False @@ -184,4 +184,3 @@ class Decoder(srd.Decoder): self.handle_bits(pins[1:]) else: self.find_clk_edge(pins[0], pins[1:]) - diff --git a/decoders/rgb_led_spi/__init__.py b/decoders/rgb_led_spi/__init__.py index 3d41ea5..a5a7ad6 100644 --- a/decoders/rgb_led_spi/__init__.py +++ b/decoders/rgb_led_spi/__init__.py @@ -24,4 +24,3 @@ values that are clocked over SPI in RGB values. ''' from .pd import * - diff --git a/decoders/rgb_led_spi/pd.py b/decoders/rgb_led_spi/pd.py index ca0b113..d7d8e58 100644 --- a/decoders/rgb_led_spi/pd.py +++ b/decoders/rgb_led_spi/pd.py @@ -60,9 +60,7 @@ class Decoder(srd.Decoder): return red, green, blue = self.mosi_bytes - rgb_value = int(red) << 16 - rgb_value |= int(green) << 8 - rgb_value |= int(blue) + rgb_value = int(red) << 16 | int(green) << 8 | int(blue) self.cmd_es = es self.putx([0, ['#%.6x' % rgb_value]]) diff --git a/decoders/rtc8564/__init__.py b/decoders/rtc8564/__init__.py index 9a397b1..65aa640 100644 --- a/decoders/rtc8564/__init__.py +++ b/decoders/rtc8564/__init__.py @@ -24,4 +24,3 @@ RTC-8564 JE/NB real-time clock (RTC) protocol. ''' from .pd import * - diff --git a/decoders/rtc8564/pd.py b/decoders/rtc8564/pd.py index 5f031e2..e95ff10 100644 --- a/decoders/rtc8564/pd.py +++ b/decoders/rtc8564/pd.py @@ -252,4 +252,3 @@ class Decoder(srd.Decoder): self.state = 'IDLE' else: pass # TODO? - diff --git a/decoders/sdcard_spi/__init__.py b/decoders/sdcard_spi/__init__.py index 293b654..60f6d98 100644 --- a/decoders/sdcard_spi/__init__.py +++ b/decoders/sdcard_spi/__init__.py @@ -67,4 +67,3 @@ SPI mode properties (differences to SD mode): ''' from .pd import * - diff --git a/decoders/sdcard_spi/pd.py b/decoders/sdcard_spi/pd.py index 6bd0be7..cbf59d7 100644 --- a/decoders/sdcard_spi/pd.py +++ b/decoders/sdcard_spi/pd.py @@ -228,7 +228,7 @@ class Decoder(srd.Decoder): if len(self.read_buf) < 16 + 4: return self.cmd_es = self.es - self.read_buf = self.read_buf[4:] ### TODO: Document or redo. + self.read_buf = self.read_buf[4:] # TODO: Document or redo. self.putx([9, ['CSD: %s' % self.read_buf]]) # TODO: Decode all bits. self.read_buf = [] @@ -439,4 +439,3 @@ class Decoder(srd.Decoder): handle_response(miso) self.state = 'IDLE' - diff --git a/decoders/spi/__init__.py b/decoders/spi/__init__.py index a1f0f1c..6579905 100644 --- a/decoders/spi/__init__.py +++ b/decoders/spi/__init__.py @@ -30,4 +30,3 @@ data is decoded on every clock transition (depending on SPI mode). ''' from .pd import * - diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py index 96c0689..374d22b 100644 --- a/decoders/spi/pd.py +++ b/decoders/spi/pd.py @@ -282,4 +282,3 @@ class Decoder(srd.Decoder): raise MissingDataError('Either MISO or MOSI (or both) pins required.') self.find_clk_edge(miso, mosi, clk, cs) - diff --git a/decoders/tlc5620/__init__.py b/decoders/tlc5620/__init__.py index c615760..6992361 100644 --- a/decoders/tlc5620/__init__.py +++ b/decoders/tlc5620/__init__.py @@ -23,4 +23,3 @@ The Texas Instruments TLC5620 is an 8-bit quad DAC. ''' from .pd import * - diff --git a/decoders/tlc5620/pd.py b/decoders/tlc5620/pd.py index 6e7c454..2a407d1 100644 --- a/decoders/tlc5620/pd.py +++ b/decoders/tlc5620/pd.py @@ -128,4 +128,3 @@ class Decoder(srd.Decoder): self.oldclk = clk self.oldload = load self.oldldac = ldac - diff --git a/decoders/uart/__init__.py b/decoders/uart/__init__.py index f3c0693..d40a7c9 100644 --- a/decoders/uart/__init__.py +++ b/decoders/uart/__init__.py @@ -39,4 +39,3 @@ or others. ''' from .pd import * - diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index 63ea50d..fef3aa5 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -173,7 +173,7 @@ class Decoder(srd.Decoder): def metadata(self, key, value): if key == srd.SRD_CONF_SAMPLERATE: - self.samplerate = value; + self.samplerate = value # The width of one UART bit in number of samples. self.bit_width = float(self.samplerate) / float(self.options['baudrate']) @@ -359,4 +359,3 @@ class Decoder(srd.Decoder): # Save current RX/TX values for the next round. self.oldbit[rxtx] = signal - diff --git a/decoders/usb_packet/__init__.py b/decoders/usb_packet/__init__.py index 06b67b9..e308652 100644 --- a/decoders/usb_packet/__init__.py +++ b/decoders/usb_packet/__init__.py @@ -42,4 +42,3 @@ http://www.usb.org/developers/docs/ ''' from .pd import * - diff --git a/decoders/usb_packet/pd.py b/decoders/usb_packet/pd.py index 4716dd7..1bbf580 100644 --- a/decoders/usb_packet/pd.py +++ b/decoders/usb_packet/pd.py @@ -338,4 +338,3 @@ class Decoder(srd.Decoder): self.bits, self.state = [], 'WAIT FOR SOP' else: pass # TODO: Error - diff --git a/decoders/usb_signalling/__init__.py b/decoders/usb_signalling/__init__.py index 2311b1f..1f6adbf 100644 --- a/decoders/usb_signalling/__init__.py +++ b/decoders/usb_signalling/__init__.py @@ -49,4 +49,3 @@ http://www.usb.org/developers/docs/ ''' from .pd import * - diff --git a/decoders/usb_signalling/pd.py b/decoders/usb_signalling/pd.py index 59db0d4..8ba55d9 100644 --- a/decoders/usb_signalling/pd.py +++ b/decoders/usb_signalling/pd.py @@ -240,4 +240,3 @@ class Decoder(srd.Decoder): self.get_bit(sym) elif self.state == 'GET EOP': self.get_eop(sym) - diff --git a/decoders/xfp/__init__.py b/decoders/xfp/__init__.py index fa4e8a2..664967d 100644 --- a/decoders/xfp/__init__.py +++ b/decoders/xfp/__init__.py @@ -38,4 +38,3 @@ The XFP specification is available here: ''' from .pd import * - diff --git a/decoders/xfp/pd.py b/decoders/xfp/pd.py index b8ec8ed..9a6543c 100644 --- a/decoders/xfp/pd.py +++ b/decoders/xfp/pd.py @@ -644,4 +644,3 @@ class Decoder(srd.Decoder): self.annotate("AUX1 monitoring", aux) aux = AUX_TYPES[data[0] & 0x0f] self.annotate("AUX2 monitoring", aux) -