From: Uwe Hermann Date: Fri, 6 Dec 2019 21:35:30 +0000 (+0100) Subject: Obsolete gpib and iec PDs in favor of ieee488. X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=185db8f1dd104444a63b080ed9e02f20a1b20a58;hp=bca4fea3c8e8447a768e816e51c6f1d9e78a2d05;p=libsigrokdecode.git Obsolete gpib and iec PDs in favor of ieee488. --- diff --git a/decoders/gpib/__init__.py b/decoders/gpib/__init__.py deleted file mode 100644 index 3b546ef..0000000 --- a/decoders/gpib/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2016 Rudolf Reuter -## -## 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 -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, see . -## - -''' -This protocol decoder can decode the GPIB (IEEE-488) protocol. -''' - -from .pd import Decoder diff --git a/decoders/gpib/pd.py b/decoders/gpib/pd.py deleted file mode 100644 index f3497f4..0000000 --- a/decoders/gpib/pd.py +++ /dev/null @@ -1,171 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2016 Rudolf Reuter -## -## 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 -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, see . -## - -import sigrokdecode as srd - -class Decoder(srd.Decoder): - api_version = 3 - id = 'gpib' - name = 'GPIB' - longname = 'General Purpose Interface Bus' - desc = 'IEEE-488 General Purpose Interface Bus (GPIB / HPIB).' - license = 'gplv2+' - inputs = ['logic'] - outputs = [] - tags = ['PC'] - channels = ( - {'id': 'dio1' , 'name': 'DIO1', 'desc': 'Data I/O bit 1'}, - {'id': 'dio2' , 'name': 'DIO2', 'desc': 'Data I/O bit 2'}, - {'id': 'dio3' , 'name': 'DIO3', 'desc': 'Data I/O bit 3'}, - {'id': 'dio4' , 'name': 'DIO4', 'desc': 'Data I/O bit 4'}, - {'id': 'dio5' , 'name': 'DIO5', 'desc': 'Data I/O bit 5'}, - {'id': 'dio6' , 'name': 'DIO6', 'desc': 'Data I/O bit 6'}, - {'id': 'dio7' , 'name': 'DIO7', 'desc': 'Data I/O bit 7'}, - {'id': 'dio8' , 'name': 'DIO8', 'desc': 'Data I/O bit 8'}, - {'id': 'eoi', 'name': 'EOI', 'desc': 'End or identify'}, - {'id': 'dav', 'name': 'DAV', 'desc': 'Data valid'}, - {'id': 'nrfd', 'name': 'NRFD', 'desc': 'Not ready for data'}, - {'id': 'ndac', 'name': 'NDAC', 'desc': 'Not data accepted'}, - {'id': 'ifc', 'name': 'IFC', 'desc': 'Interface clear'}, - {'id': 'srq', 'name': 'SRQ', 'desc': 'Service request'}, - {'id': 'atn', 'name': 'ATN', 'desc': 'Attention'}, - {'id': 'ren', 'name': 'REN', 'desc': 'Remote enable'}, - ) - annotations = ( - ('items', 'Items'), - ('gpib', 'DAT/CMD'), - ('eoi', 'EOI'), - ) - annotation_rows = ( - ('bytes', 'Bytes', (0,)), - ('gpib', 'DAT/CMD', (1,)), - ('eoi', 'EOI', (2,)), - ) - - def __init__(self): - self.reset() - - def reset(self): - self.items = [] - self.itemcount = 0 - self.saved_item = None - self.saved_ATN = False - self.saved_EOI = False - self.samplenum = 0 - self.ss_item = self.es_item = None - self.first = True - - def start(self): - self.out_ann = self.register(srd.OUTPUT_ANN) - - def putb(self, data): - self.put(self.ss_item, self.es_item, self.out_ann, data) - - def handle_bits(self, datapins): - dbyte = 0x20 - dATN = False - item2 = False - dEOI = False - item3 = False - # If this is the first item in a word, save its sample number. - if self.itemcount == 0: - self.ss_word = self.samplenum - - # Get the bits for this item. - item = 0 - for i in range(8): - item |= datapins[i] << i - - item = item ^ 0xff # Invert data byte. - self.items.append(item) - self.itemcount += 1 - - if datapins[14] == 0: - item2 = True - if datapins[8] == 0: - item3 = True - - if self.first: - # Save the start sample and item for later (no output yet). - self.ss_item = self.samplenum - self.first = False - self.saved_item = item - self.saved_ATN = item2 - self.saved_EOI = item3 - else: - # Output the saved item. - dbyte = self.saved_item - dATN = self.saved_ATN - dEOI = self.saved_EOI - self.es_item = self.samplenum - self.putb([0, ['%02X' % self.saved_item]]) - - # Encode item byte to GPIB convention. - self.strgpib = ' ' - if dATN: # ATN, decode commands. - if dbyte == 0x01: self.strgpib = 'GTL' - if dbyte == 0x04: self.strgpib = 'SDC' - if dbyte == 0x05: self.strgpib = 'PPC' - if dbyte == 0x08: self.strgpib = 'GET' - if dbyte == 0x09: self.strgpib = 'TCT' - if dbyte == 0x11: self.strgpib = 'LLO' - if dbyte == 0x14: self.strgpib = 'DCL' - if dbyte == 0x15: self.strgpib = 'PPU' - if dbyte == 0x18: self.strgpib = 'SPE' - if dbyte == 0x19: self.strgpib = 'SPD' - if dbyte == 0x3f: self.strgpib = 'UNL' - if dbyte == 0x5f: self.strgpib = 'UNT' - if dbyte > 0x1f and dbyte < 0x3f: # Address Listener. - self.strgpib = 'L' + chr(dbyte + 0x10) - if dbyte > 0x3f and dbyte < 0x5f: # Address Talker - self.strgpib = 'T' + chr(dbyte - 0x10) - else: - if dbyte > 0x1f and dbyte < 0x7f: - self.strgpib = chr(dbyte) - if dbyte == 0x0a: - self.strgpib = 'LF' - if dbyte == 0x0d: - self.strgpib = 'CR' - - self.putb([1, [self.strgpib]]) - self.strEOI = ' ' - if dEOI: - self.strEOI = 'EOI' - self.putb([2, [self.strEOI]]) - - self.ss_item = self.samplenum - self.saved_item = item - self.saved_ATN = item2 - self.saved_EOI = item3 - - if self.itemcount < 16: - return - - self.itemcount, self.items = 0, [] - - def decode(self): - - # Inspect samples at falling edge of DAV. But make sure to also - # start inspection when the capture happens to start with low - # DAV level. - waitcond = [{9: 'l'}] - while True: - pins = self.wait(waitcond) - self.handle_bits(pins) - waitcond[0][9] = 'f' diff --git a/decoders/iec/__init__.py b/decoders/iec/__init__.py deleted file mode 100644 index fa0d96f..0000000 --- a/decoders/iec/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2017 Marcus Comstedt -## -## 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 -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, see . -## - -''' -This protocol decoder can decode the Commodore serial IEEE-488 (IEC) protocol. -''' - -from .pd import Decoder diff --git a/decoders/iec/pd.py b/decoders/iec/pd.py deleted file mode 100644 index ae0f8e9..0000000 --- a/decoders/iec/pd.py +++ /dev/null @@ -1,167 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2017 Marcus Comstedt -## -## 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 -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. -## -## This program is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with this program; if not, see . -## - -import sigrokdecode as srd - -step_wait_conds = ( - [{2: 'f'}, {0: 'l', 1: 'h'}], - [{2: 'f'}, {0: 'h', 1: 'h'}, {1: 'l'}], - [{2: 'f'}, {0: 'f'}, {1: 'l'}], - [{2: 'f'}, {1: 'e'}], -) - -class Decoder(srd.Decoder): - api_version = 3 - id = 'iec' - name = 'IEC' - longname = 'Commodore IEC bus' - desc = 'Commodore serial IEEE-488 (IEC) bus protocol.' - license = 'gplv2+' - inputs = ['logic'] - outputs = [] - tags = ['PC', 'Retro computing'] - channels = ( - {'id': 'data', 'name': 'DATA', 'desc': 'Data I/O'}, - {'id': 'clk', 'name': 'CLK', 'desc': 'Clock'}, - {'id': 'atn', 'name': 'ATN', 'desc': 'Attention'}, - ) - optional_channels = ( - {'id': 'srq', 'name': 'SRQ', 'desc': 'Service request'}, - ) - annotations = ( - ('items', 'Items'), - ('gpib', 'DAT/CMD'), - ('eoi', 'EOI'), - ) - annotation_rows = ( - ('bytes', 'Bytes', (0,)), - ('gpib', 'DAT/CMD', (1,)), - ('eoi', 'EOI', (2,)), - ) - - def __init__(self): - self.reset() - - def reset(self): - self.saved_ATN = False - self.saved_EOI = False - self.ss_item = self.es_item = None - self.step = 0 - self.bits = 0 - self.numbits = 0 - - def start(self): - self.out_ann = self.register(srd.OUTPUT_ANN) - - def putb(self, data): - self.put(self.ss_item, self.es_item, self.out_ann, data) - - def handle_bits(self): - # Output the saved item. - dbyte = self.bits - dATN = self.saved_ATN - dEOI = self.saved_EOI - self.es_item = self.samplenum - self.putb([0, ['%02X' % dbyte]]) - - # Encode item byte to GPIB convention. - self.strgpib = ' ' - if dATN: # ATN, decode commands. - # Note: Commands < 0x20 are not used on IEC bus. - if dbyte == 0x01: self.strgpib = 'GTL' - if dbyte == 0x04: self.strgpib = 'SDC' - if dbyte == 0x05: self.strgpib = 'PPC' - if dbyte == 0x08: self.strgpib = 'GET' - if dbyte == 0x09: self.strgpib = 'TCT' - if dbyte == 0x11: self.strgpib = 'LLO' - if dbyte == 0x14: self.strgpib = 'DCL' - if dbyte == 0x15: self.strgpib = 'PPU' - if dbyte == 0x18: self.strgpib = 'SPE' - if dbyte == 0x19: self.strgpib = 'SPD' - - if dbyte == 0x3f: self.strgpib = 'UNL' - if dbyte == 0x5f: self.strgpib = 'UNT' - if dbyte > 0x1f and dbyte < 0x3f: # Address listener. - self.strgpib = 'L' + chr(dbyte + 0x10) - if dbyte > 0x3f and dbyte < 0x5f: # Address talker. - self.strgpib = 'T' + chr(dbyte - 0x10) - if dbyte > 0x5f and dbyte < 0x70: # Channel reopen. - self.strgpib = 'R' + chr(dbyte - 0x30) - if dbyte > 0xdf and dbyte < 0xf0: # Channel close. - self.strgpib = 'C' + chr(dbyte - 0xb0) - if dbyte > 0xef: # Channel open. - self.strgpib = 'O' + chr(dbyte - 0xc0) - else: - if dbyte > 0x1f and dbyte < 0x7f: - self.strgpib = chr(dbyte) - if dbyte == 0x0a: - self.strgpib = 'LF' - if dbyte == 0x0d: - self.strgpib = 'CR' - - self.putb([1, [self.strgpib]]) - self.strEOI = ' ' - if dEOI: - self.strEOI = 'EOI' - self.putb([2, [self.strEOI]]) - - def decode(self): - while True: - - data, clk, atn, srq = self.wait(step_wait_conds[self.step]) - - if self.matched[0]: - # Falling edge on ATN, reset step. - self.step = 0 - - if self.step == 0: - # Don't use self.matched[1] here since we might come from - # a step with different conds due to the code above. - if data == 0 and clk == 1: - # Rising edge on CLK while DATA is low: Ready to send. - self.step = 1 - elif self.step == 1: - if data == 1 and clk == 1: - # Rising edge on DATA while CLK is high: Ready for data. - self.ss_item = self.samplenum - self.saved_ATN = not atn - self.saved_EOI = False - self.bits = 0 - self.numbits = 0 - self.step = 2 - elif clk == 0: - # CLK low again, transfer aborted. - self.step = 0 - elif self.step == 2: - if data == 0 and clk == 1: - # DATA goes low while CLK is still high, EOI confirmed. - self.saved_EOI = True - elif clk == 0: - self.step = 3 - elif self.step == 3: - if self.matched[1]: - if clk == 1: - # Rising edge on CLK; latch DATA. - self.bits |= data << self.numbits - elif clk == 0: - # Falling edge on CLK; end of bit. - self.numbits += 1 - if self.numbits == 8: - self.handle_bits() - self.step = 0