X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fds1307%2Fpd.py;h=1a49f9a1b31baa77ea476949c4f525ccc5d57647;hb=e28f7aee3b96afeb543e0c3c29e3950ddd61a490;hp=bb904e7e4d17d0f9cddd91c744bca2a02d016039;hpb=0169f19c53e195df2f96c4df731ad3214c59e20a;p=libsigrokdecode.git diff --git a/decoders/ds1307/pd.py b/decoders/ds1307/pd.py index bb904e7..1a49f9a 100644 --- a/decoders/ds1307/pd.py +++ b/decoders/ds1307/pd.py @@ -19,8 +19,6 @@ ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## -# Dallas DS1307 RTC protocol decoder - import sigrokdecode as srd days_of_week = [ @@ -38,7 +36,7 @@ def bcd2int(b): return (b & 0x0f) + ((b >> 4) * 10) class Decoder(srd.Decoder): - api_version = 1 + api_version = 2 id = 'ds1307' name = 'DS1307' longname = 'Dallas DS1307' @@ -46,12 +44,9 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['i2c'] outputs = ['ds1307'] - probes = [] - optional_probes = [] - options = {} - annotations = [ - ['Text', 'Human-readable text'], - ] + annotations = ( + ('text', 'Human-readable text'), + ) def __init__(self, **kwargs): self.state = 'IDLE' @@ -103,12 +98,12 @@ class Decoder(srd.Decoder): def decode(self, ss, es, data): cmd, databyte = data - # Store the start/end samples of this I2C packet. + # Store the start/end samples of this I²C packet. self.ss, self.es = ss, es # State machine. if self.state == 'IDLE': - # Wait for an I2C START condition. + # Wait for an I²C START condition. if cmd != 'START': return self.state = 'GET SLAVE ADDR' @@ -169,6 +164,4 @@ class Decoder(srd.Decoder): self.state = 'IDLE' else: pass # TODO? - else: - raise Exception('Invalid state: %s' % self.state)