X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fpjon%2Fpd.py;h=b23cfb846ab0cbe301f8db69a06520189e8ecf53;hb=c4aaef2588e962d0bd99f7a88841fcf53956da6b;hp=fdc9de785efba1e2982d2028a11322173dbb48ae;hpb=9dc13f0da80e72c6f2fc3a50aadbbd80d8b93f51;p=libsigrokdecode.git diff --git a/decoders/pjon/pd.py b/decoders/pjon/pd.py index fdc9de7..b23cfb8 100644 --- a/decoders/pjon/pd.py +++ b/decoders/pjon/pd.py @@ -74,7 +74,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['pjon_link'] outputs = [] - tags = ['Embedded'] + tags = ['Embedded/industrial'] annotations = ( ('rx_info', 'Receiver ID'), ('hdr_cfg', 'Header config'), @@ -130,6 +130,7 @@ class Decoder(srd.Decoder): return # Emit "communication relation" details. + # TODO Include the service ID (port number) as well? text = [] if self.frame_rx_id is not None: text.append("RX {}".format(self.frame_rx_id[-1])) @@ -236,7 +237,7 @@ class Decoder(srd.Decoder): text.append('svc_id' if self.cfg_port else '-') # port aka service ID text.append('ack_mode' if self.cfg_async_ack else '-') # async response text.append('ack' if self.cfg_sync_ack else '-') # synchronous response - text.append('tx_info' if self.cfg_tx_info else '-') + text.append('tx_info' if self.cfg_tx_info else '-') # sender address text.append('bus_id' if self.cfg_shared else '-') # "shared" vs "local" text = ' '.join(text) bits = '{:08b}'.format(b) @@ -255,7 +256,7 @@ class Decoder(srd.Decoder): # Get the size of variable width fields, to calculate the size # of the packet overhead (the part that is not the payload data). # This lets us derive the payload length when we later receive - # the packet length. + # the frame's total length. u8_fmt = '>B' u16_fmt = '>H' u32_fmt = '>L' @@ -339,7 +340,7 @@ class Decoder(srd.Decoder): # The wire communicates the total packet length. Some of it is # overhead (non-payload data), while its volume is variable in - # size (dpends on the header configuration). + # size (depends on the header configuration). # # Derive the payload size from previously observed flags. Update # the previously registered field description (the second last @@ -381,12 +382,13 @@ class Decoder(srd.Decoder): # across meta and end checksums in a frame's fields. caption = 'META' if is_meta else 'END' crc_len = 8 if is_meta else 32 if self.cfg_crc32 else 8 + crc_bytes = crc_len // 8 crc_fmt = '{:08x}' if crc_len == 32 else '{:02x}' have_text = crc_fmt.format(have) # Check received against expected checksum. Emit warnings. warn_texts = [] - data = self.frame_bytes[:-1] + data = self.frame_bytes[:-crc_bytes] want = calc_crc32(data) if crc_len == 32 else calc_crc8(data) if want != have: want_text = crc_fmt.format(want)