X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fonewire%2Fonewire.py;h=9ece3797813dac7b2f114759b3ad6b72ec5af209;hb=de2f532821bab1bef235ee65b38b0f4427bb9d5c;hp=3f4a817ce160b41da1ce4c92e71c9cc3a33d738c;hpb=d2b6e141c5c6707897b19cfd7ccf4f3ffd21d501;p=libsigrokdecode.git diff --git a/decoders/onewire/onewire.py b/decoders/onewire/onewire.py index 3f4a817..9ece379 100644 --- a/decoders/onewire/onewire.py +++ b/decoders/onewire/onewire.py @@ -169,9 +169,12 @@ class Decoder(srd.Decoder): self.put(self.lnk_fall, self.samplenum, self.out_ann, [ANN_DEC, ['NET: ROM COMMAND: 0x' + hex(self.net_data)]]) print ("DEBUG: ROM_COMMAND=0x%02x t0=%d t+=%d" % (self.net_data, self.lnk_fall, self.samplenum)) - if (self.net_data in [0x33, 0x0f]): + if (self.net_data == 0x33): # READ ROM self.net_state = "ADDRESS" + elif (self.net_data == 0x0f): + # READ ROM TODO + self.net_state = "ADDRESS" elif (self.net_data == 0xcc): # SKIP ROM self.net_state = "CONTROL COMMAND" @@ -190,22 +193,12 @@ class Decoder(srd.Decoder): elif (self.net_state == "ADDRESS"): # family code (1B) + serial number (6B) + CRC (1B) if (self.collect_data((1+6+1)*8)): - self.net_family_code = (self.net_data >> (( 0)*8)) & 0xff - self.net_serial_number = (self.net_data >> (( 1)*8)) & 0xffffffffffff - self.net_crc = (self.net_data >> ((6+1)*8)) & 0xff - print ("DEBUG: net_family_code =0x%001x" % (self.net_family_code )) - print ("DEBUG: net_serial_number=0x%012x" % (self.net_serial_number)) - print ("DEBUG: net_crc =0x%001x" % (self.net_crc )) + self.net_address = self.net_data & 0xffffffffffffffff self.net_state = "CONTROL COMMAND" elif (self.net_state == "SEARCH"): # family code (1B) + serial number (6B) + CRC (1B) if (self.collect_search((1+6+1)*8)): - self.net_family_code = (self.net_data >> (( 0)*8)) & 0xff - self.net_serial_number = (self.net_data >> (( 1)*8)) & 0xffffffffffff - self.net_crc = (self.net_data >> ((6+1)*8)) & 0xff - print ("DEBUG: net_family_code =0x%001x" % (self.net_family_code )) - print ("DEBUG: net_serial_number=0x%012x" % (self.net_serial_number)) - print ("DEBUG: net_crc =0x%001x" % (self.net_crc )) + self.net_address = self.net_data & 0xffffffffffffffff self.net_state = "CONTROL COMMAND" elif (self.net_state == "CONTROL COMMAND"): if (self.collect_data(8)): @@ -214,10 +207,7 @@ class Decoder(srd.Decoder): self.put(self.lnk_fall, self.samplenum, self.out_ann, [ANN_DEC, ['NET: FUNCTION COMMAND: 0x' + hex(self.net_data)]]) print ("DEBUG: FUNCTION_COMMAND=0x%02x t0=%d t+=%d" % (self.net_data, self.lnk_fall, self.samplenum)) - if (self.net_data == 0x44): - # CONVERT TEMPERATURE - self.net_state = "TODO" - elif (self.net_data == 0x48): + if (self.net_data == 0x48): # COPY SCRATCHPAD self.net_state = "TODO" elif (self.net_data == 0x4e): @@ -232,6 +222,11 @@ class Decoder(srd.Decoder): elif (self.net_data == 0xb4): # READ POWER SUPPLY self.net_state = "TODO" + else: + # unsupported commands + self.net_state = "UNDEFINED" + elif (self.net_state == "UNDEFINED"): + pass else: raise Exception('Invalid net_state: %s' % self.net_state) elif (self.lnk_event != "NONE"):