##
## This file is part of the libsigrokdecode project.
##
-## Copyright (C) 2011-2013 Uwe Hermann <uwe@hermann-uwe.de>
+## Copyright (C) 2011-2014 Uwe Hermann <uwe@hermann-uwe.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
-# UART protocol decoder
-
import sigrokdecode as srd
'''
# TODO: Options to invert the signal(s).
}
annotations = [
- ['RX data', 'UART RX data'],
- ['TX data', 'UART TX data'],
- ['Start bits', 'UART start bits'],
- ['Parity bits', 'UART parity bits'],
- ['Stop bits', 'UART stop bits'],
- ['Warnings', 'Warnings'],
+ ['rx-data', 'UART RX data'],
+ ['tx-data', 'UART TX data'],
+ ['start-bits', 'UART start bits'],
+ ['parity-bits', 'UART parity bits'],
+ ['stop-bits', 'UART stop bits'],
+ ['warnings', 'Warnings'],
]
+ binary = (
+ ('rx', 'RX dump'),
+ ('tx', 'TX dump'),
+ ('rxtx', 'RX/TX dump'),
+ )
def putx(self, rxtx, data):
s, halfbit = self.startsample[rxtx], int(self.bit_width / 2)
s, halfbit = self.samplenum, int(self.bit_width / 2)
self.put(s - halfbit, s + halfbit, self.out_proto, data)
+ def putbin(self, rxtx, data):
+ s, halfbit = self.startsample[rxtx], int(self.bit_width / 2)
+ self.put(s - halfbit, self.samplenum + halfbit, self.out_bin, data)
+
def __init__(self, **kwargs):
self.samplerate = None
self.samplenum = 0
def start(self):
self.out_proto = self.register(srd.OUTPUT_PYTHON)
+ self.out_bin = self.register(srd.OUTPUT_BINARY)
self.out_ann = self.register(srd.OUTPUT_ANN)
def metadata(self, key, value):
else:
raise Exception('Invalid data format option: %s' % f)
+ self.putbin(rxtx, (rxtx, bytes([b])))
+ self.putbin(rxtx, (2, bytes([b])))
+
def get_parity_bit(self, rxtx, signal):
# If no parity is used/configured, skip to the next state immediately.
if self.options['parity_type'] == 'none':