From: Uwe Hermann Date: Tue, 24 May 2016 19:42:02 +0000 (+0200) Subject: Move common/ directory into decoders/. X-Git-Tag: libsigrokdecode-0.5.0~166 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=135b790c851c52400279e7c932e1f900d91ae5cc;p=libsigrokdecode.git Move common/ directory into decoders/. This simplifies cross-platform handling of the Python/decoder paths and module installation/dist a bit and also fixes bug #804. --- diff --git a/Makefile.am b/Makefile.am index 1a1074e..a8df8f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,12 +23,11 @@ AM_LIBTOOLFLAGS = --silent GNUMAKEFLAGS = --no-print-directory DECODERS_DIR = $(pkgdatadir)/decoders -COMMON_DIR = $(pkgdatadir)/common # Do not hard-code the decoders location on Windows. if WIN32 AM_CPPFLAGS = else -AM_CPPFLAGS = -DDECODERS_DIR='"$(DECODERS_DIR)"' -DCOMMON_DIR='"$(COMMON_DIR)"' +AM_CPPFLAGS = -DDECODERS_DIR='"$(DECODERS_DIR)"' endif # The tests CFLAGS are a superset of the libsigrokdecode CFLAGS. @@ -89,20 +88,14 @@ ChangeLog: dist-hook: ChangeLog $(MKDIR_P) $(distdir)/tools cp ${top_srcdir}/tools/install-decoders $(distdir)/tools - $(MKDIR_P) $(distdir)/common - cp -a ${top_srcdir}/common $(distdir) $(MKDIR_P) $(distdir)/decoders ${top_srcdir}/tools/install-decoders -i ${top_srcdir}/decoders \ -o $(distdir)/decoders -install-common: - $(MKDIR_P) $(DESTDIR)$(COMMON_DIR) - cp -a ${top_srcdir}/common $(DESTDIR)$(pkgdatadir) - install-decoders: $(MKDIR_P) $(DESTDIR)$(DECODERS_DIR) $(PYTHON3) ${top_srcdir}/tools/install-decoders \ -i ${top_srcdir}/decoders -o $(DESTDIR)$(DECODERS_DIR) -install-data-hook: install-common install-decoders +install-data-hook: install-decoders diff --git a/common/plugtrx/__init__.py b/common/plugtrx/__init__.py deleted file mode 100644 index 8dd0822..0000000 --- a/common/plugtrx/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2016 Bert Vermeulen -## -## 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 3 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 . -## - -from .mod import * diff --git a/common/plugtrx/mod.py b/common/plugtrx/mod.py deleted file mode 100644 index 3d1b66d..0000000 --- a/common/plugtrx/mod.py +++ /dev/null @@ -1,192 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2016 Bert Vermeulen -## -## 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 3 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 module contains definitions for use by pluggable network adapters, -# such as SFP, XFP etc. - -MODULE_ID = { - 0x01: 'GBIC', - 0x02: 'Integrated module/connector', - 0x03: 'SFP', - 0x04: '300-pin XBI', - 0x05: 'XENPAK', - 0x06: 'XFP', - 0x07: 'XFF', - 0x08: 'XFP-E', - 0x09: 'XPAK', - 0x0a: 'X2', -} - -ALARM_THRESHOLDS = { - 0: 'Temp high alarm', - 2: 'Temp low alarm', - 4: 'Temp high warning', - 6: 'Temp low warning', - 16: 'Bias high alarm', - 18: 'Bias low alarm', - 20: 'Bias high warning', - 22: 'Bias low warning', - 24: 'TX power high alarm', - 26: 'TX power low alarm', - 28: 'TX power high warning', - 30: 'TX power low warning', - 32: 'RX power high alarm', - 34: 'RX power low alarm', - 36: 'RX power high warning', - 38: 'RX power low warning', - 40: 'AUX 1 high alarm', - 42: 'AUX 1 low alarm', - 44: 'AUX 1 high warning', - 46: 'AUX 1 low warning', - 48: 'AUX 2 high alarm', - 50: 'AUX 2 low alarm', - 52: 'AUX 2 high warning', - 54: 'AUX 2 low warning', -} - -AD_READOUTS = { - 0: 'Module temperature', - 4: 'TX bias current', - 6: 'Measured TX output power', - 8: 'Measured RX input power', - 10: 'AUX 1 measurement', - 12: 'AUX 2 measurement', -} - -GCS_BITS = [ - 'TX disable', - 'Soft TX disable', - 'MOD_NR', - 'P_Down', - 'Soft P_Down', - 'Interrupt', - 'RX_LOS', - 'Data_Not_Ready', - 'TX_NR', - 'TX_Fault', - 'TX_CDR not locked', - 'RX_NR', - 'RX_CDR not locked', -] - -CONNECTOR = { - 0x01: 'SC', - 0x02: 'Fibre Channel style 1 copper', - 0x03: 'Fibre Channel style 2 copper', - 0x04: 'BNC/TNC', - 0x05: 'Fibre Channel coax', - 0x06: 'FiberJack', - 0x07: 'LC', - 0x08: 'MT-RJ', - 0x09: 'MU', - 0x0a: 'SG', - 0x0b: 'Optical pigtail', - 0x20: 'HSSDC II', - 0x21: 'Copper pigtail', -} - -TRANSCEIVER = [ - # 10GB Ethernet - ['10GBASE-SR', '10GBASE-LR', '10GBASE-ER', '10GBASE-LRM', '10GBASE-SW', - '10GBASE-LW', '10GBASE-EW'], - # 10GB Fibre Channel - ['1200-MX-SN-I', '1200-SM-LL-L', 'Extended Reach 1550 nm', - 'Intermediate reach 1300 nm FP'], - # 10GB Copper - [], - # 10GB low speed - ['1000BASE-SX / 1xFC MMF', '1000BASE-LX / 1xFC SMF', '2xFC MMF', - '2xFC SMF', 'OC48-SR', 'OC48-IR', 'OC48-LR'], - # 10GB SONET/SDH interconnect - ['I-64.1r', 'I-64.1', 'I-64.2r', 'I-64.2', 'I-64.3', 'I-64.5'], - # 10GB SONET/SDH short haul - ['S-64.1', 'S-64.2a', 'S-64.2b', 'S-64.3a', 'S-64.3b', 'S-64.5a', 'S-64.5b'], - # 10GB SONET/SDH long haul - ['L-64.1', 'L-64.2a', 'L-64.2b', 'L-64.2c', 'L-64.3', 'G.959.1 P1L1-2D2'], - # 10GB SONET/SDH very long haul - ['V-64.2a', 'V-64.2b', 'V-64.3'], -] - -SERIAL_ENCODING = [ - '64B/66B', - '8B/10B', - 'SONET scrambled', - 'NRZ', - 'RZ', -] - -XMIT_TECH = [ - '850 nm VCSEL', - '1310 nm VCSEL', - '1550 nm VCSEL', - '1310 nm FP', - '1310 nm DFB', - '1550 nm DFB', - '1310 nm EML' - '1550 nm EML' - 'copper', -] - -CDR = [ - '9.95Gb/s', - '10.3Gb/s', - '10.5Gb/s', - '10.7Gb/s', - '11.1Gb/s', - '(unknown)', - 'lineside loopback mode', - 'XFI loopback mode', -] - -DEVICE_TECH = [ - ['no wavelength control', 'sctive wavelength control'], - ['uncooled transmitter device', 'cooled transmitter'], - ['PIN detector', 'APD detector'], - ['transmitter not tunable', 'transmitter tunable'], -] - -ENHANCED_OPTS = [ - 'VPS', - 'soft TX_DISABLE', - 'soft P_Down', - 'VPS LV regulator mode', - 'VPS bypassed regulator mode', - 'active FEC control', - 'wavelength tunability', - 'CMU', -] - -AUX_TYPES = [ - 'not implemented', - 'APD bias voltage', - '(unknown)', - 'TEC current', - 'laser temperature', - 'laser wavelength', - '5V supply voltage', - '3.3V supply voltage', - '1.8V supply voltage', - '-5.2V supply voltage', - '5V supply current', - '(unknown)', - '(unknown)', - '3.3V supply current', - '1.8V supply current', - '-5.2V supply current', -] diff --git a/common/sdcard/__init__.py b/common/sdcard/__init__.py deleted file mode 100644 index cf09d9d..0000000 --- a/common/sdcard/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2012-2014 Uwe Hermann -## -## 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, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -## - -from .mod import * diff --git a/common/sdcard/mod.py b/common/sdcard/mod.py deleted file mode 100644 index f553cf1..0000000 --- a/common/sdcard/mod.py +++ /dev/null @@ -1,186 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2012-2014 Uwe Hermann -## -## 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, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -## - -# Normal commands (CMD) -# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't -# seem to be mentioned in the spec, but aren't marked as reserved either. -cmd_names = { - 0: 'GO_IDLE_STATE', - 1: 'SEND_OP_COND', # Reserved in SD mode - 2: 'ALL_SEND_CID', - 3: 'SEND_RELATIVE_ADDR', - 4: 'SET_DSR', - 5: 'IO_SEND_OP_COND', # SDIO-only - 6: 'SWITCH_FUNC', # New since spec 1.10 - 7: 'SELECT/DESELECT_CARD', - 8: 'SEND_IF_COND', - 9: 'SEND_CSD', - 10: 'SEND_CID', - 11: 'VOLTAGE_SWITCH', - 12: 'STOP_TRANSMISSION', - 13: 'SEND_STATUS', - # 14: Reserved - 15: 'GO_INACTIVE_STATE', - 16: 'SET_BLOCKLEN', - 17: 'READ_SINGLE_BLOCK', - 18: 'READ_MULTIPLE_BLOCK', - 19: 'SEND_TUNING_BLOCK', - 20: 'SPEED_CLASS_CONTROL', - # 21-22: Reserved - 23: 'SET_BLOCK_COUNT', - 24: 'WRITE_BLOCK', - 25: 'WRITE_MULTIPLE_BLOCK', - 26: 'Reserved for manufacturer', - 27: 'PROGRAM_CSD', - 28: 'SET_WRITE_PROT', - 29: 'CLR_WRITE_PROT', - 30: 'SEND_WRITE_PROT', - # 31: Reserved - 32: 'ERASE_WR_BLK_START', # SPI mode: ERASE_WR_BLK_START_ADDR - 33: 'ERASE_WR_BLK_END', # SPI mode: ERASE_WR_BLK_END_ADDR - 34: 'Reserved for CMD6', # New since spec 1.10 - 35: 'Reserved for CMD6', # New since spec 1.10 - 36: 'Reserved for CMD6', # New since spec 1.10 - 37: 'Reserved for CMD6', # New since spec 1.10 - 38: 'ERASE', - # 39: Reserved - 40: 'Reserved for security specification', - # 41: Reserved - 42: 'LOCK_UNLOCK', - # 43-49: Reserved - 50: 'Reserved for CMD6', # New since spec 1.10 - # 51: Reserved - 52: 'IO_RW_DIRECT', # SDIO-only - 53: 'IO_RW_EXTENDED', # SDIO-only - 54: 'Unknown', - 55: 'APP_CMD', - 56: 'GEN_CMD', - 57: 'Reserved for CMD6', # New since spec 1.10 - 58: 'READ_OCR', # Reserved in SD mode - 59: 'CRC_ON_OFF', # Reserved in SD mode - 60: 'Reserved for manufacturer', - 61: 'Reserved for manufacturer', - 62: 'Reserved for manufacturer', - 63: 'Reserved for manufacturer', -} - -# Application-specific commands (ACMD) -# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't -# seem to be mentioned in the spec, but aren't marked as reserved either. -acmd_names = { - # 1-5: Reserved - 6: 'SET_BUS_WIDTH', - # 7-12: Reserved - 13: 'SD_STATUS', - 14: 'Reserved for Security Application', - 15: 'Reserved for Security Application', - 16: 'Reserved for Security Application', - # 17: Reserved - 18: 'Reserved for SD security applications', - # 19-21: Reserved - 22: 'SEND_NUM_WR_BLOCKS', - 23: 'SET_WR_BLK_ERASE_COUNT', - # 24: Reserved - 25: 'Reserved for SD security applications', - 26: 'Reserved for SD security applications', - 27: 'Reserved for security specification', - 28: 'Reserved for security specification', - # 29: Reserved - 30: 'Reserved for security specification', - 31: 'Reserved for security specification', - 32: 'Reserved for security specification', - 33: 'Reserved for security specification', - 34: 'Reserved for security specification', - 35: 'Reserved for security specification', - # 36-37: Reserved - 38: 'Reserved for SD security applications', - # 39-40: Reserved - 41: 'SD_SEND_OP_COND', - 42: 'SET_CLR_CARD_DETECT', - 43: 'Reserved for SD security applications', - 44: 'Reserved for SD security applications', - 45: 'Reserved for SD security applications', - 46: 'Reserved for SD security applications', - 47: 'Reserved for SD security applications', - 48: 'Reserved for SD security applications', - 49: 'Reserved for SD security applications', - 50: 'Unknown', - 51: 'SEND_SCR', - 52: 'Reserved for security specification', - 53: 'Reserved for security specification', - 54: 'Reserved for security specification', - 55: 'Non-existant', # Doesn't exist (equivalent to CMD55) - 56: 'Reserved for security specification', - 57: 'Reserved for security specification', - 58: 'Reserved for security specification', - 59: 'Reserved for security specification', - 60: 'Unknown', - 61: 'Unknown', - 62: 'Unknown', - 63: 'Unknown', -} - -accepted_voltages = { - 0b0001: '2.7-3.6V', - 0b0010: 'reserved for low voltage range', - 0b0100: 'reserved', - 0b1000: 'reserved', - # All other values: "not defined". -} - -card_status = { - 0: 'Reserved for manufacturer test mode', - 1: 'Reserved for manufacturer test mode', - 2: 'Reserved for application specific commands', - 3: 'AKE_SEQ_ERROR', - 4: 'Reserved for SDIO card', - 5: 'APP_CMD', - 6: 'Unknown', - 7: 'Unknown', - 8: 'READY_FOR_DATA', - 9: 'CURRENT_STATE', # CURRENT_STATE is a 4-bit value (decimal: 0..15). - 10: 'CURRENT_STATE', - 11: 'CURRENT_STATE', - 12: 'CURRENT_STATE', - 13: 'ERASE_RESET', - 14: 'CARD_ECC_DISABLED', - 15: 'WP_ERASE_SKIP', - 16: 'CSD_OVERWRITE', - 17: 'Reserved for DEFERRED_RESPONSE', # See eSD addendum - 18: 'Reserved', - 19: 'ERROR', - 20: 'CC_ERROR', - 21: 'CARD_ECC_FAILED', - 22: 'ILLEGAL_COMMAND', - 23: 'COM_CRC_ERROR', - 24: 'LOCK_UNLOCK_FAILED', - 25: 'CARD_IS_LOCKED', - 26: 'WP_VIOLATION', - 27: 'ERASE_PARAM', - 28: 'ERASE_SEQ_ERROR', - 29: 'BLOCK_LEN_ERROR', - 30: 'ADDRESS_ERROR', - 31: 'OUT_OF_RANGE', -} - -sd_status = { - # 311:0: Reserved for manufacturer - # 391:312: Reserved -} diff --git a/common/srdhelper/__init__.py b/common/srdhelper/__init__.py deleted file mode 100644 index cf09d9d..0000000 --- a/common/srdhelper/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2012-2014 Uwe Hermann -## -## 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, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -## - -from .mod import * diff --git a/common/srdhelper/mod.py b/common/srdhelper/mod.py deleted file mode 100644 index e65ab17..0000000 --- a/common/srdhelper/mod.py +++ /dev/null @@ -1,23 +0,0 @@ -## -## This file is part of the libsigrokdecode project. -## -## Copyright (C) 2012-2014 Uwe Hermann -## -## 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, write to the Free Software -## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -## - -# Return the specified BCD number (max. 8 bits) as integer. -def bcd2int(b): - return (b & 0x0f) + ((b >> 4) * 10) diff --git a/decoders/common/__init__.py b/decoders/common/__init__.py new file mode 100644 index 0000000..c597431 --- /dev/null +++ b/decoders/common/__init__.py @@ -0,0 +1,20 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2016 Uwe Hermann +## +## 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, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + diff --git a/decoders/common/plugtrx/__init__.py b/decoders/common/plugtrx/__init__.py new file mode 100644 index 0000000..8dd0822 --- /dev/null +++ b/decoders/common/plugtrx/__init__.py @@ -0,0 +1,20 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2016 Bert Vermeulen +## +## 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 3 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 . +## + +from .mod import * diff --git a/decoders/common/plugtrx/mod.py b/decoders/common/plugtrx/mod.py new file mode 100644 index 0000000..3d1b66d --- /dev/null +++ b/decoders/common/plugtrx/mod.py @@ -0,0 +1,192 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2016 Bert Vermeulen +## +## 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 3 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 module contains definitions for use by pluggable network adapters, +# such as SFP, XFP etc. + +MODULE_ID = { + 0x01: 'GBIC', + 0x02: 'Integrated module/connector', + 0x03: 'SFP', + 0x04: '300-pin XBI', + 0x05: 'XENPAK', + 0x06: 'XFP', + 0x07: 'XFF', + 0x08: 'XFP-E', + 0x09: 'XPAK', + 0x0a: 'X2', +} + +ALARM_THRESHOLDS = { + 0: 'Temp high alarm', + 2: 'Temp low alarm', + 4: 'Temp high warning', + 6: 'Temp low warning', + 16: 'Bias high alarm', + 18: 'Bias low alarm', + 20: 'Bias high warning', + 22: 'Bias low warning', + 24: 'TX power high alarm', + 26: 'TX power low alarm', + 28: 'TX power high warning', + 30: 'TX power low warning', + 32: 'RX power high alarm', + 34: 'RX power low alarm', + 36: 'RX power high warning', + 38: 'RX power low warning', + 40: 'AUX 1 high alarm', + 42: 'AUX 1 low alarm', + 44: 'AUX 1 high warning', + 46: 'AUX 1 low warning', + 48: 'AUX 2 high alarm', + 50: 'AUX 2 low alarm', + 52: 'AUX 2 high warning', + 54: 'AUX 2 low warning', +} + +AD_READOUTS = { + 0: 'Module temperature', + 4: 'TX bias current', + 6: 'Measured TX output power', + 8: 'Measured RX input power', + 10: 'AUX 1 measurement', + 12: 'AUX 2 measurement', +} + +GCS_BITS = [ + 'TX disable', + 'Soft TX disable', + 'MOD_NR', + 'P_Down', + 'Soft P_Down', + 'Interrupt', + 'RX_LOS', + 'Data_Not_Ready', + 'TX_NR', + 'TX_Fault', + 'TX_CDR not locked', + 'RX_NR', + 'RX_CDR not locked', +] + +CONNECTOR = { + 0x01: 'SC', + 0x02: 'Fibre Channel style 1 copper', + 0x03: 'Fibre Channel style 2 copper', + 0x04: 'BNC/TNC', + 0x05: 'Fibre Channel coax', + 0x06: 'FiberJack', + 0x07: 'LC', + 0x08: 'MT-RJ', + 0x09: 'MU', + 0x0a: 'SG', + 0x0b: 'Optical pigtail', + 0x20: 'HSSDC II', + 0x21: 'Copper pigtail', +} + +TRANSCEIVER = [ + # 10GB Ethernet + ['10GBASE-SR', '10GBASE-LR', '10GBASE-ER', '10GBASE-LRM', '10GBASE-SW', + '10GBASE-LW', '10GBASE-EW'], + # 10GB Fibre Channel + ['1200-MX-SN-I', '1200-SM-LL-L', 'Extended Reach 1550 nm', + 'Intermediate reach 1300 nm FP'], + # 10GB Copper + [], + # 10GB low speed + ['1000BASE-SX / 1xFC MMF', '1000BASE-LX / 1xFC SMF', '2xFC MMF', + '2xFC SMF', 'OC48-SR', 'OC48-IR', 'OC48-LR'], + # 10GB SONET/SDH interconnect + ['I-64.1r', 'I-64.1', 'I-64.2r', 'I-64.2', 'I-64.3', 'I-64.5'], + # 10GB SONET/SDH short haul + ['S-64.1', 'S-64.2a', 'S-64.2b', 'S-64.3a', 'S-64.3b', 'S-64.5a', 'S-64.5b'], + # 10GB SONET/SDH long haul + ['L-64.1', 'L-64.2a', 'L-64.2b', 'L-64.2c', 'L-64.3', 'G.959.1 P1L1-2D2'], + # 10GB SONET/SDH very long haul + ['V-64.2a', 'V-64.2b', 'V-64.3'], +] + +SERIAL_ENCODING = [ + '64B/66B', + '8B/10B', + 'SONET scrambled', + 'NRZ', + 'RZ', +] + +XMIT_TECH = [ + '850 nm VCSEL', + '1310 nm VCSEL', + '1550 nm VCSEL', + '1310 nm FP', + '1310 nm DFB', + '1550 nm DFB', + '1310 nm EML' + '1550 nm EML' + 'copper', +] + +CDR = [ + '9.95Gb/s', + '10.3Gb/s', + '10.5Gb/s', + '10.7Gb/s', + '11.1Gb/s', + '(unknown)', + 'lineside loopback mode', + 'XFI loopback mode', +] + +DEVICE_TECH = [ + ['no wavelength control', 'sctive wavelength control'], + ['uncooled transmitter device', 'cooled transmitter'], + ['PIN detector', 'APD detector'], + ['transmitter not tunable', 'transmitter tunable'], +] + +ENHANCED_OPTS = [ + 'VPS', + 'soft TX_DISABLE', + 'soft P_Down', + 'VPS LV regulator mode', + 'VPS bypassed regulator mode', + 'active FEC control', + 'wavelength tunability', + 'CMU', +] + +AUX_TYPES = [ + 'not implemented', + 'APD bias voltage', + '(unknown)', + 'TEC current', + 'laser temperature', + 'laser wavelength', + '5V supply voltage', + '3.3V supply voltage', + '1.8V supply voltage', + '-5.2V supply voltage', + '5V supply current', + '(unknown)', + '(unknown)', + '3.3V supply current', + '1.8V supply current', + '-5.2V supply current', +] diff --git a/decoders/common/sdcard/__init__.py b/decoders/common/sdcard/__init__.py new file mode 100644 index 0000000..cf09d9d --- /dev/null +++ b/decoders/common/sdcard/__init__.py @@ -0,0 +1,21 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2012-2014 Uwe Hermann +## +## 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, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +from .mod import * diff --git a/decoders/common/sdcard/mod.py b/decoders/common/sdcard/mod.py new file mode 100644 index 0000000..f553cf1 --- /dev/null +++ b/decoders/common/sdcard/mod.py @@ -0,0 +1,186 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2012-2014 Uwe Hermann +## +## 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, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +# Normal commands (CMD) +# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't +# seem to be mentioned in the spec, but aren't marked as reserved either. +cmd_names = { + 0: 'GO_IDLE_STATE', + 1: 'SEND_OP_COND', # Reserved in SD mode + 2: 'ALL_SEND_CID', + 3: 'SEND_RELATIVE_ADDR', + 4: 'SET_DSR', + 5: 'IO_SEND_OP_COND', # SDIO-only + 6: 'SWITCH_FUNC', # New since spec 1.10 + 7: 'SELECT/DESELECT_CARD', + 8: 'SEND_IF_COND', + 9: 'SEND_CSD', + 10: 'SEND_CID', + 11: 'VOLTAGE_SWITCH', + 12: 'STOP_TRANSMISSION', + 13: 'SEND_STATUS', + # 14: Reserved + 15: 'GO_INACTIVE_STATE', + 16: 'SET_BLOCKLEN', + 17: 'READ_SINGLE_BLOCK', + 18: 'READ_MULTIPLE_BLOCK', + 19: 'SEND_TUNING_BLOCK', + 20: 'SPEED_CLASS_CONTROL', + # 21-22: Reserved + 23: 'SET_BLOCK_COUNT', + 24: 'WRITE_BLOCK', + 25: 'WRITE_MULTIPLE_BLOCK', + 26: 'Reserved for manufacturer', + 27: 'PROGRAM_CSD', + 28: 'SET_WRITE_PROT', + 29: 'CLR_WRITE_PROT', + 30: 'SEND_WRITE_PROT', + # 31: Reserved + 32: 'ERASE_WR_BLK_START', # SPI mode: ERASE_WR_BLK_START_ADDR + 33: 'ERASE_WR_BLK_END', # SPI mode: ERASE_WR_BLK_END_ADDR + 34: 'Reserved for CMD6', # New since spec 1.10 + 35: 'Reserved for CMD6', # New since spec 1.10 + 36: 'Reserved for CMD6', # New since spec 1.10 + 37: 'Reserved for CMD6', # New since spec 1.10 + 38: 'ERASE', + # 39: Reserved + 40: 'Reserved for security specification', + # 41: Reserved + 42: 'LOCK_UNLOCK', + # 43-49: Reserved + 50: 'Reserved for CMD6', # New since spec 1.10 + # 51: Reserved + 52: 'IO_RW_DIRECT', # SDIO-only + 53: 'IO_RW_EXTENDED', # SDIO-only + 54: 'Unknown', + 55: 'APP_CMD', + 56: 'GEN_CMD', + 57: 'Reserved for CMD6', # New since spec 1.10 + 58: 'READ_OCR', # Reserved in SD mode + 59: 'CRC_ON_OFF', # Reserved in SD mode + 60: 'Reserved for manufacturer', + 61: 'Reserved for manufacturer', + 62: 'Reserved for manufacturer', + 63: 'Reserved for manufacturer', +} + +# Application-specific commands (ACMD) +# Unlisted items are 'Reserved' as per SD spec. The 'Unknown' items don't +# seem to be mentioned in the spec, but aren't marked as reserved either. +acmd_names = { + # 1-5: Reserved + 6: 'SET_BUS_WIDTH', + # 7-12: Reserved + 13: 'SD_STATUS', + 14: 'Reserved for Security Application', + 15: 'Reserved for Security Application', + 16: 'Reserved for Security Application', + # 17: Reserved + 18: 'Reserved for SD security applications', + # 19-21: Reserved + 22: 'SEND_NUM_WR_BLOCKS', + 23: 'SET_WR_BLK_ERASE_COUNT', + # 24: Reserved + 25: 'Reserved for SD security applications', + 26: 'Reserved for SD security applications', + 27: 'Reserved for security specification', + 28: 'Reserved for security specification', + # 29: Reserved + 30: 'Reserved for security specification', + 31: 'Reserved for security specification', + 32: 'Reserved for security specification', + 33: 'Reserved for security specification', + 34: 'Reserved for security specification', + 35: 'Reserved for security specification', + # 36-37: Reserved + 38: 'Reserved for SD security applications', + # 39-40: Reserved + 41: 'SD_SEND_OP_COND', + 42: 'SET_CLR_CARD_DETECT', + 43: 'Reserved for SD security applications', + 44: 'Reserved for SD security applications', + 45: 'Reserved for SD security applications', + 46: 'Reserved for SD security applications', + 47: 'Reserved for SD security applications', + 48: 'Reserved for SD security applications', + 49: 'Reserved for SD security applications', + 50: 'Unknown', + 51: 'SEND_SCR', + 52: 'Reserved for security specification', + 53: 'Reserved for security specification', + 54: 'Reserved for security specification', + 55: 'Non-existant', # Doesn't exist (equivalent to CMD55) + 56: 'Reserved for security specification', + 57: 'Reserved for security specification', + 58: 'Reserved for security specification', + 59: 'Reserved for security specification', + 60: 'Unknown', + 61: 'Unknown', + 62: 'Unknown', + 63: 'Unknown', +} + +accepted_voltages = { + 0b0001: '2.7-3.6V', + 0b0010: 'reserved for low voltage range', + 0b0100: 'reserved', + 0b1000: 'reserved', + # All other values: "not defined". +} + +card_status = { + 0: 'Reserved for manufacturer test mode', + 1: 'Reserved for manufacturer test mode', + 2: 'Reserved for application specific commands', + 3: 'AKE_SEQ_ERROR', + 4: 'Reserved for SDIO card', + 5: 'APP_CMD', + 6: 'Unknown', + 7: 'Unknown', + 8: 'READY_FOR_DATA', + 9: 'CURRENT_STATE', # CURRENT_STATE is a 4-bit value (decimal: 0..15). + 10: 'CURRENT_STATE', + 11: 'CURRENT_STATE', + 12: 'CURRENT_STATE', + 13: 'ERASE_RESET', + 14: 'CARD_ECC_DISABLED', + 15: 'WP_ERASE_SKIP', + 16: 'CSD_OVERWRITE', + 17: 'Reserved for DEFERRED_RESPONSE', # See eSD addendum + 18: 'Reserved', + 19: 'ERROR', + 20: 'CC_ERROR', + 21: 'CARD_ECC_FAILED', + 22: 'ILLEGAL_COMMAND', + 23: 'COM_CRC_ERROR', + 24: 'LOCK_UNLOCK_FAILED', + 25: 'CARD_IS_LOCKED', + 26: 'WP_VIOLATION', + 27: 'ERASE_PARAM', + 28: 'ERASE_SEQ_ERROR', + 29: 'BLOCK_LEN_ERROR', + 30: 'ADDRESS_ERROR', + 31: 'OUT_OF_RANGE', +} + +sd_status = { + # 311:0: Reserved for manufacturer + # 391:312: Reserved +} diff --git a/decoders/common/srdhelper/__init__.py b/decoders/common/srdhelper/__init__.py new file mode 100644 index 0000000..cf09d9d --- /dev/null +++ b/decoders/common/srdhelper/__init__.py @@ -0,0 +1,21 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2012-2014 Uwe Hermann +## +## 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, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +from .mod import * diff --git a/decoders/common/srdhelper/mod.py b/decoders/common/srdhelper/mod.py new file mode 100644 index 0000000..e65ab17 --- /dev/null +++ b/decoders/common/srdhelper/mod.py @@ -0,0 +1,23 @@ +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2012-2014 Uwe Hermann +## +## 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, write to the Free Software +## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +## + +# Return the specified BCD number (max. 8 bits) as integer. +def bcd2int(b): + return (b & 0x0f) + ((b >> 4) * 10) diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py index 4f956aa..0f1d3d1 100644 --- a/decoders/dcf77/pd.py +++ b/decoders/dcf77/pd.py @@ -20,7 +20,7 @@ import sigrokdecode as srd import calendar -from srdhelper import bcd2int +from common.srdhelper import bcd2int class SamplerateError(Exception): pass diff --git a/decoders/ds1307/pd.py b/decoders/ds1307/pd.py index 6d862af..f181fd9 100644 --- a/decoders/ds1307/pd.py +++ b/decoders/ds1307/pd.py @@ -21,7 +21,7 @@ import re import sigrokdecode as srd -from srdhelper import bcd2int +from common.srdhelper import bcd2int days_of_week = ( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', diff --git a/decoders/rtc8564/pd.py b/decoders/rtc8564/pd.py index 4bcd096..4ecc15a 100644 --- a/decoders/rtc8564/pd.py +++ b/decoders/rtc8564/pd.py @@ -19,7 +19,7 @@ ## import sigrokdecode as srd -from srdhelper import bcd2int +from common.srdhelper import bcd2int def reg_list(): l = [] diff --git a/decoders/sdcard_sd/pd.py b/decoders/sdcard_sd/pd.py index 442a563..79c2074 100644 --- a/decoders/sdcard_sd/pd.py +++ b/decoders/sdcard_sd/pd.py @@ -19,7 +19,7 @@ ## import sigrokdecode as srd -from sdcard import (cmd_names, acmd_names, accepted_voltages, card_status, sd_status) +from common.sdcard import (cmd_names, acmd_names, accepted_voltages, card_status, sd_status) class Decoder(srd.Decoder): api_version = 2 diff --git a/decoders/sdcard_spi/pd.py b/decoders/sdcard_spi/pd.py index e069b6e..45490ad 100644 --- a/decoders/sdcard_spi/pd.py +++ b/decoders/sdcard_spi/pd.py @@ -19,7 +19,7 @@ ## import sigrokdecode as srd -from sdcard import (cmd_names, acmd_names) +from common.sdcard import (cmd_names, acmd_names) class Decoder(srd.Decoder): api_version = 2 diff --git a/decoders/xfp/pd.py b/decoders/xfp/pd.py index 26f3311..27135e5 100644 --- a/decoders/xfp/pd.py +++ b/decoders/xfp/pd.py @@ -18,7 +18,7 @@ ## import sigrokdecode as srd -from plugtrx import (MODULE_ID, ALARM_THRESHOLDS, AD_READOUTS, GCS_BITS, +from common.plugtrx import (MODULE_ID, ALARM_THRESHOLDS, AD_READOUTS, GCS_BITS, CONNECTOR, TRANSCEIVER, SERIAL_ENCODING, XMIT_TECH, CDR, DEVICE_TECH, ENHANCED_OPTS, AUX_TYPES) diff --git a/srd.c b/srd.c index c74d2de..2947ca8 100644 --- a/srd.c +++ b/srd.c @@ -169,12 +169,6 @@ SRD_API int srd_init(const char *path) } } #ifdef DECODERS_DIR - /* Common modules for use by any decoder. */ - if ((ret = srd_decoder_searchpath_add(COMMON_DIR)) != SRD_OK) { - Py_Finalize(); - return ret; - } - /* Hardcoded decoders install location, if defined. */ if ((ret = srd_decoder_searchpath_add(DECODERS_DIR)) != SRD_OK) { Py_Finalize(); diff --git a/tools/install-decoders b/tools/install-decoders index 465c70e..8445da5 100755 --- a/tools/install-decoders +++ b/tools/install-decoders @@ -24,7 +24,7 @@ from shutil import copy from getopt import getopt -def install(srcdir, dstdir): +def install(srcdir, dstdir, s): worklist = [] for pd in os.listdir(srcdir): pd_dir = srcdir + '/' + pd @@ -39,9 +39,10 @@ def install(srcdir, dstdir): install_list.extend(config_get_extra_install(pd_file)) elif f[-3:] == '.py': install_list.append(f) - worklist.append((pd, pd_dir, install_list)) + if install_list: + worklist.append((pd, pd_dir, install_list)) - print("Installing %d protocol decoders:" % len(worklist)) + print("Installing %d %s:" % (len(worklist), s)) col = 0 for pd, pd_dir, install_list in worklist: msg = pd + ' ' @@ -107,6 +108,7 @@ except Exception as e: if len(args) != 0 or dst is None: usage() -install(src, dst) +install(src, dst, 'protocol decoders') +install(src + '/common', dst + '/common', 'common modules')