2
0
forked from Ivasoft/DSView

Improve the hardware abstraction layer

This commit is contained in:
DreamSourceLab
2018-07-08 17:48:18 +08:00
parent c7cba6a79b
commit 856e1803a7
105 changed files with 2745 additions and 2944 deletions

View File

@@ -250,7 +250,7 @@ class Decoder(srd.Decoder):
if not (self.have_miso or self.have_mosi):
raise ChannelError('Either MISO or MOSI (or both) pins required.')
if (self.mode == 0 or self.mode == 3):
self.exp_oldclk = 0
self.exp_oldclk = 0
self.exp_clk = 1
else:
self.exp_oldclk = 1
@@ -272,7 +272,7 @@ class Decoder(srd.Decoder):
#if not self.no_cs_notification and not self.have_cs:
# self.put(0, 0, self.out_python, ['CS-CHANGE', None, None])
# self.no_cs_notification = True
if (self.oldcs, cs) == (self.asserted_oldcs, self.asserted_cs):
#self.ss_transfer = self.samplenum
#self.misobytes = []
@@ -288,6 +288,6 @@ class Decoder(srd.Decoder):
elif not self.have_cs or cs == self.asserted_cs:
if (self.oldclk, clk) == (self.exp_oldclk, self.exp_clk):
#Sample on rising/falling clock edge
self.handle_bit(miso, mosi, clk, cs)
self.handle_bit(miso, mosi, clk, cs)
self.oldclk, self.oldcs = clk, cs

View File

@@ -281,7 +281,7 @@ class Decoder(srd.Decoder):
(signal,) = pins
if self.options['invert'] == 'yes':
signal = not signal
signal = not signal
# State machine.
if self.state == 'FIND START':

View File

@@ -179,7 +179,7 @@ class Decoder(srd.Decoder):
self.bits[1][2] = self.samplenum
if self.bitcount == 7:
self.bitwidth = self.bits[1][2] - self.bits[2][2]
self.bits[0][2] += self.bitwidth
self.bits[0][2] += self.bitwidth
# Return if we haven't collected all 8 + 1 bits, yet.
if self.bitcount < 7:
@@ -233,7 +233,7 @@ class Decoder(srd.Decoder):
self.bits[1][2] = self.samplenum
if self.bitcount == 7:
self.bitwidth = self.bits[1][2] - self.bits[2][2]
self.bits[0][2] += self.bitwidth
self.bits[0][2] += self.bitwidth
# Return if we haven't collected all 8 + 1 bits, yet.
if self.bitcount < 7:

View File

@@ -252,7 +252,7 @@ class Decoder(srd.Decoder):
if not (self.have_miso or self.have_mosi):
raise ChannelError('Either MISO or MOSI (or both) pins required.')
if (self.mode == 0 or self.mode == 3):
self.exp_oldclk = 0
self.exp_oldclk = 0
self.exp_clk = 1
else:
self.exp_oldclk = 1
@@ -273,7 +273,7 @@ class Decoder(srd.Decoder):
if not self.no_cs_notification and not self.have_cs:
self.put(0, 0, self.out_python, ['CS-CHANGE', None, None])
self.no_cs_notification = True
if (self.oldcs, cs) == (self.asserted_oldcs, self.asserted_cs):
self.ss_transfer = self.samplenum
self.misobytes = []
@@ -289,6 +289,6 @@ class Decoder(srd.Decoder):
elif not self.have_cs or cs == self.asserted_cs:
if (self.oldclk, clk) == (self.exp_oldclk, self.exp_clk):
#Sample on rising/falling clock edge
self.handle_bit(miso, mosi, clk, cs)
self.handle_bit(miso, mosi, clk, cs)
self.oldclk, self.oldcs = clk, cs

View File

@@ -281,7 +281,7 @@ class Decoder(srd.Decoder):
(signal,) = pins
if self.options['invert'] == 'yes':
signal = not signal
signal = not signal
# State machine.
if self.state == 'FIND START':

View File

@@ -47,7 +47,7 @@ class Decoder(srd.Decoder):
self.syncbuf = []
self.prevsample = 0
self.stream = 0
self.ss_stream = None
self.stream_ss = None
self.bytenum = 0
def start(self):
@@ -57,10 +57,10 @@ class Decoder(srd.Decoder):
def stream_changed(self, ss, stream):
if self.stream != stream:
if self.stream != 0:
self.put(self.ss_stream, ss, self.out_ann,
self.put(self.stream_ss, ss, self.out_ann,
[0, ['Stream %d' % self.stream, 'S%d' % self.stream]])
self.stream = stream
self.ss_stream = ss
self.stream_ss = ss
def emit_byte(self, ss, es, byte):
if self.stream == self.options['stream']:

View File

@@ -1,20 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2016 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
## 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
##

View File

@@ -1,20 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2016 Bert Vermeulen <bert@biot.com>
##
## 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 <http://www.gnu.org/licenses/>.
##
from .mod import *

View File

@@ -1,192 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2016 Bert Vermeulen <bert@biot.com>
##
## 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 <http://www.gnu.org/licenses/>.
##
# 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',
]

View File

@@ -1,21 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-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
## 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 *

View File

@@ -1,186 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-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
## 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
}

View File

@@ -1,21 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-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
## 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 *

View File

@@ -1,23 +0,0 @@
##
## This file is part of the libsigrokdecode project.
##
## Copyright (C) 2012-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
## 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)

View File

@@ -20,7 +20,10 @@
import sigrokdecode as srd
import calendar
from common.srdhelper import bcd2int
# Return the specified BCD number (max. 8 bits) as integer.
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)
class SamplerateError(Exception):
pass
@@ -65,7 +68,7 @@ class Decoder(srd.Decoder):
('warnings', 'Warnings', (19,)),
)
def __init__(self):
def __init__(self, **kwargs):
self.samplerate = None
self.state = 'WAIT FOR RISING EDGE'
self.oldpins = None

View File

@@ -14,8 +14,7 @@
## 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
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
'''

View File

@@ -14,8 +14,7 @@
## 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
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
import sigrokdecode as srd

View File

@@ -21,7 +21,6 @@
import re
import sigrokdecode as srd
from common.srdhelper import bcd2int
days_of_week = (
'Sunday', 'Monday', 'Tuesday', 'Wednesday',
@@ -52,6 +51,10 @@ def regs_and_bits():
l += [('bit-' + re.sub('\/| ', '-', b).lower(), b + ' bit') for b in bits]
return tuple(l)
# Return the specified BCD number (max. 8 bits) as integer.
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)
class Decoder(srd.Decoder):
api_version = 2
id = 'ds1307'
@@ -75,7 +78,7 @@ class Decoder(srd.Decoder):
('warnings', 'Warnings', (28,)),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'IDLE'
self.hours = -1
self.minutes = -1

View File

@@ -73,12 +73,12 @@ class Decoder(srd.Decoder):
('binary', 'Binary'),
)
def __init__(self):
def __init__(self, **kwargs):
self.reset()
def start(self):
self.out_ann = self.register(srd.OUTPUT_ANN)
self.out_binary = self.register(srd.OUTPUT_BINARY)
self.out_bin = self.register(srd.OUTPUT_BINARY)
self.chip = chips[self.options['chip']]
self.addr_counter = self.options['addr_counter']
@@ -86,7 +86,7 @@ class Decoder(srd.Decoder):
self.put(self.ss_block, self.es_block, self.out_ann, data)
def putbin(self, data):
self.put(self.ss_block, self.es_block, self.out_binary, data)
self.put(self.ss_block, self.es_block, self.out_bin, data)
def putbits(self, bit1, bit2, bits, data):
self.put(bits[bit1][1], bits[bit2][2], self.out_ann, data)
@@ -165,7 +165,7 @@ class Decoder(srd.Decoder):
self.putb([cls, ['%s (%s): %s' % (s, self.addr_and_len(), \
self.hexbytes(self.chip['addr_bytes'])),
'%s (%s)' % (s, self.addr_and_len()), s, a, s[0]]])
self.putbin([0, bytes(self.bytebuf[self.chip['addr_bytes']:])])
self.putbin((0, bytes(self.bytebuf[self.chip['addr_bytes']:])))
def addr_and_len(self):
if self.chip['addr_bytes'] == 1:
@@ -215,7 +215,7 @@ class Decoder(srd.Decoder):
[8, ['Data', 'D']])
self.putb([11, ['Current address read: %02X' % self.bytebuf[0],
'Current address read', 'Cur addr read', 'CAR', 'C']])
self.putbin([0, bytes([self.bytebuf[0]])])
self.putbin((0, bytes([self.bytebuf[0]])))
self.addr_counter += 1
elif self.is_random_access_read:
# Random access read: word address, one data byte.

View File

@@ -74,12 +74,12 @@ class Decoder(srd.Decoder):
self.oldpl = 0
self.oldsamplenum = 0
self.last_bit_pos = 0
self.ss_first = 0
self.first_ss = 0
self.first_one = 0
self.state = 'HEADER'
self.data = 0
self.data_bits = 0
self.ss_data = 0
self.data_ss = 0
self.data_parity = 0
self.payload_cnt = 0
self.data_col_parity = [0, 0, 0, 0, 0, 0]
@@ -105,14 +105,14 @@ class Decoder(srd.Decoder):
if self.first_one > 0:
self.first_one += 1
if self.first_one == 9:
self.put(self.ss_first, es, self.out_ann,
self.put(self.first_ss, es, self.out_ann,
[1, ['Header', 'Head', 'He', 'H']])
self.first_one = 0
self.state = 'PAYLOAD'
return
if self.first_one == 0:
self.first_one = 1
self.ss_first = ss
self.first_ss = ss
if bit == 0:
self.first_one = 0
@@ -121,14 +121,14 @@ class Decoder(srd.Decoder):
if self.state == 'PAYLOAD':
self.payload_cnt += 1
if self.data_bits == 0:
self.ss_data = ss
self.data_ss = ss
self.data = 0
self.data_parity = 0
self.data_bits += 1
if self.data_bits == 5:
s = 'Version/customer' if self.payload_cnt <= 10 else 'Data'
c = 2 if self.payload_cnt <= 10 else 3
self.put(self.ss_data, ss, self.out_ann,
self.put(self.data_ss, ss, self.out_ann,
[c, [s + ': %X' % self.data, '%X' % self.data]])
s = 'OK' if self.data_parity == bit else 'ERROR'
c = 4 if s == 'OK' else 5
@@ -150,7 +150,7 @@ class Decoder(srd.Decoder):
if self.state == 'TRAILER':
self.payload_cnt += 1
if self.data_bits == 0:
self.ss_data = ss
self.data_ss = ss
self.data = 0
self.data_parity = 0
self.data_bits += 1
@@ -172,7 +172,7 @@ class Decoder(srd.Decoder):
# Emit an annotation for valid-looking tags.
all_col_parity_ok = (self.data_col_parity[1:5] == self.col_parity[1:5])
if all_col_parity_ok and self.all_row_parity_ok:
self.put(self.ss_first, es, self.out_ann,
self.put(self.first_ss, es, self.out_ann,
[9, ['Tag: %010X' % self.tag, 'Tag', 'T']])
self.tag = 0

View File

@@ -14,8 +14,7 @@
## 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
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
'''

View File

@@ -14,8 +14,7 @@
## 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
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
import sigrokdecode as srd

View File

@@ -283,7 +283,18 @@ class Decoder(srd.Decoder):
ptype, data1, data2 = data
if ptype == 'CS-CHANGE':
if ptype == 'TRANSFER':
if self.cmd:
# Check if we got the minimum number of data bytes
# after the command byte.
if len(self.mb) < self.min:
self.warn((ss, ss), 'missing data bytes')
elif self.mb:
self.finish_command((self.mb_s, self.mb_e))
self.next()
self.cs_was_released = True
elif ptype == 'CS-CHANGE':
if data1 is None:
if data2 is None:
self.requirements_met = False
@@ -303,8 +314,8 @@ class Decoder(srd.Decoder):
self.finish_command((self.mb_s, self.mb_e))
self.next()
self.cs_was_released = True
elif ptype == 'DATA' and self.cs_was_released:
self.cs_was_released = True
elif ptype == 'DATA':
mosi, miso = data1, data2
pos = (ss, es)

View File

@@ -182,7 +182,7 @@ class Decoder(srd.Decoder):
self.cnt_overdrive_presence = int(samplerate * x) - 1
x = float(self.options['cnt_overdrive_reset']) / 1000000.0
self.cnt_overdrive_reset = int(samplerate * x) - 1
# Organize values into lists.
self.cnt_bit = [self.cnt_normal_bit, self.cnt_overdrive_bit]
self.cnt_presence = [self.cnt_normal_presence, self.cnt_overdrive_presence]
@@ -286,3 +286,4 @@ class Decoder(srd.Decoder):
# Wait for next slot.
self.state = 'WAIT FOR FALLING EDGE'

View File

@@ -49,7 +49,7 @@ class Decoder(srd.Decoder):
def __init__(self):
self.samplerate = None
self.oldpin = None
self.ss_packet = None
self.packet_ss = None
self.ss = None
self.es = None
self.bits = []
@@ -66,10 +66,10 @@ class Decoder(srd.Decoder):
if len(self.bits) == 24:
grb = reduce(lambda a, b: (a << 1) | b, self.bits)
rgb = (grb & 0xff0000) >> 8 | (grb & 0x00ff00) << 8 | (grb & 0x0000ff)
self.put(self.ss_packet, samplenum, self.out_ann,
self.put(self.packet_ss, samplenum, self.out_ann,
[2, ['#%06x' % rgb]])
self.bits = []
self.ss_packet = None
self.packet_ss = None
def decode(self, ss, es, data):
if not self.samplerate:
@@ -99,7 +99,7 @@ class Decoder(srd.Decoder):
self.inreset = True
self.bits = []
self.ss_packet = None
self.packet_ss = None
self.ss = None
if not self.oldpin and pin:
@@ -116,8 +116,8 @@ class Decoder(srd.Decoder):
self.bits.append(bit_)
self.handle_bits(samplenum)
if self.ss_packet is None:
self.ss_packet = samplenum
if self.packet_ss is None:
self.packet_ss = samplenum
self.ss = samplenum

View File

@@ -19,7 +19,10 @@
##
import sigrokdecode as srd
from common.srdhelper import bcd2int
# Return the specified BCD number (max. 8 bits) as integer.
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)
def reg_list():
l = []
@@ -52,7 +55,7 @@ class Decoder(srd.Decoder):
('date-time', 'Date/time', (9, 10)),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'IDLE'
self.hours = -1
self.minutes = -1

View File

@@ -1,5 +1,5 @@
##
## This file is part of the libsigrokdecode project.
## This file is part of the sigrok project.
##
## Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
##

View File

@@ -1,5 +1,5 @@
##
## This file is part of the libsigrokdecode project.
## This file is part of the sigrok project.
##
## Copyright (C) 2015 Uwe Hermann <uwe@hermann-uwe.de>
##
@@ -19,7 +19,7 @@
##
import sigrokdecode as srd
from common.sdcard import (cmd_names, acmd_names, accepted_voltages, card_status, sd_status)
from .lists import *
class Decoder(srd.Decoder):
api_version = 2
@@ -61,7 +61,7 @@ class Decoder(srd.Decoder):
('cmd', 'Commands', tuple(range(128))),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'GET COMMAND TOKEN'
self.token = []
self.oldpins = None
@@ -167,7 +167,7 @@ class Decoder(srd.Decoder):
# Handle command.
s = 'ACMD' if self.is_acmd else 'CMD'
self.cmd_str = '%s%d (%s)' % (s, self.cmd, self.cmd_name(self.cmd))
if self.cmd in (0, 2, 3, 4, 6, 7, 8, 9, 10, 13, 41, 51, 55):
if self.cmd in (0, 2, 3, 6, 7, 8, 9, 10, 13, 41, 51, 55):
self.state = 'HANDLE CMD%d' % self.cmd
else:
self.state = 'HANDLE CMD999'

View File

@@ -19,7 +19,57 @@
##
import sigrokdecode as srd
from common.sdcard import (cmd_names, acmd_names)
# Normal commands (CMD)
cmd_names = {
0: 'GO_IDLE_STATE',
1: 'SEND_OP_COND',
6: 'SWITCH_FUNC',
8: 'SEND_IF_COND',
9: 'SEND_CSD',
10: 'SEND_CID',
12: 'STOP_TRANSMISSION',
13: 'SEND_STATUS',
16: 'SET_BLOCKLEN',
17: 'READ_SINGLE_BLOCK',
18: 'READ_MULTIPLE_BLOCK',
24: 'WRITE_BLOCK',
25: 'WRITE_MULTIPLE_BLOCK',
27: 'PROGRAM_CSD',
28: 'SET_WRITE_PROT',
29: 'CLR_WRITE_PROT',
30: 'SEND_WRITE_PROT',
32: 'ERASE_WR_BLK_START_ADDR',
33: 'ERASE_WR_BLK_END_ADDR',
38: 'ERASE',
42: 'LOCK_UNLOCK',
55: 'APP_CMD',
56: 'GEN_CMD',
58: 'READ_OCR',
59: 'CRC_ON_OFF',
# CMD60-63: Reserved for manufacturer
}
# Application-specific commands (ACMD)
acmd_names = {
13: 'SD_STATUS',
18: 'Reserved for SD security applications',
22: 'SEND_NUM_WR_BLOCKS',
23: 'SET_WR_BLK_ERASE_COUNT',
25: 'Reserved for SD security applications',
26: 'Reserved for SD security applications',
38: 'Reserved for SD security applications',
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',
51: 'SEND_SCR',
}
class Decoder(srd.Decoder):
api_version = 2
@@ -46,7 +96,7 @@ class Decoder(srd.Decoder):
('cmd-reply', 'Commands/replies', tuple(range(134))),
)
def __init__(self):
def __init__(self, **kwargs):
self.state = 'IDLE'
self.ss, self.es = 0, 0
self.ss_bit, self.es_bit = 0, 0
@@ -72,12 +122,7 @@ class Decoder(srd.Decoder):
def cmd_name(self, cmd):
c = acmd_names if self.is_acmd else cmd_names
s = c.get(cmd, 'Unknown')
# SD mode names for CMD32/33: ERASE_WR_BLK_{START,END}.
# SPI mode names for CMD32/33: ERASE_WR_BLK_{START,END}_ADDR.
if cmd in (32, 33):
s += '_ADDR'
return s
return c.get(cmd, 'Unknown')
def handle_command_token(self, mosi, miso):
# Command tokens (6 bytes) are sent (MSB-first) by the host.

View File

@@ -17,8 +17,7 @@
## 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
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
'''

View File

@@ -17,8 +17,7 @@
## 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
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
import sigrokdecode as srd

View File

@@ -52,7 +52,7 @@ class Decoder(srd.Decoder):
def __init__(self):
self.oldstep = None
self.ss_prev_step = None
self.prev_step_ss = None
self.pos = 0
self.prev_speed = None
self.prev_pos = None
@@ -70,18 +70,18 @@ class Decoder(srd.Decoder):
self.unit = 'mm'
def step(self, ss, direction):
if self.ss_prev_step is not None:
delta = ss - self.ss_prev_step
if self.prev_step_ss is not None:
delta = ss - self.prev_step_ss
speed = self.samplerate / delta / self.scale
speed_txt = self.format % speed
pos_txt = self.format % (self.pos / self.scale)
self.put(self.ss_prev_step, ss, self.out_ann,
self.put(self.prev_step_ss, ss, self.out_ann,
[0, [speed_txt + ' ' + self.unit + '/s', speed_txt]])
self.put(self.ss_prev_step, ss, self.out_ann,
self.put(self.prev_step_ss, ss, self.out_ann,
[1, [pos_txt + ' ' + self.unit, pos_txt]])
self.pos += (1 if direction else -1)
self.ss_prev_step = ss
self.prev_step_ss = ss
def metadata(self, key, value):
if key == srd.SRD_CONF_SAMPLERATE:

View File

@@ -141,8 +141,8 @@ class Decoder(srd.Decoder):
self.request = {}
self.request_id = 0
self.transaction_state = 'IDLE'
self.ss_transaction = None
self.es_transaction = None
self.transaction_ss = None
self.transaction_es = None
self.transaction_ep = None
self.transaction_addr = None
self.wrote_pcap_header = False
@@ -182,7 +182,7 @@ class Decoder(srd.Decoder):
addr = self.transaction_addr
if not (addr, ep) in self.request:
self.request[(addr, ep)] = {'setup_data': [], 'data': [],
'type': None, 'ss': self.ss_transaction, 'es': None,
'type': None, 'ss': self.transaction_ss, 'es': None,
'id': self.request_id, 'addr': addr, 'ep': ep}
self.request_id += 1
request_started = 1
@@ -192,16 +192,16 @@ class Decoder(srd.Decoder):
if request['type'] in (None, 'BULK IN') and self.transaction_type == 'IN':
request['type'] = 'BULK IN'
request['data'] += self.transaction_data
request['es'] = self.es_transaction
request['es'] = self.transaction_es
self.handle_request(request_started, request_end)
elif request['type'] in (None, 'BULK OUT') and self.transaction_type == 'OUT':
request['type'] = 'BULK OUT'
request['data'] += self.transaction_data
request['es'] = self.es_transaction
request['es'] = self.transaction_es
self.handle_request(request_started, request_end)
# CONTROL, SETUP stage
elif request['type'] is None and self.transaction_type == 'SETUP':
elif request['type'] == None and self.transaction_type == 'SETUP':
request['setup_data'] = self.transaction_data
request['wLength'] = struct.unpack('<H',
bytes(self.transaction_data[6:8]))[0]
@@ -223,11 +223,11 @@ class Decoder(srd.Decoder):
# CONTROL, STATUS stage
elif request['type'] == 'SETUP IN' and self.transaction_type == 'OUT':
request['es'] = self.es_transaction
request['es'] = self.transaction_es
self.handle_request(0, request_end)
elif request['type'] == 'SETUP OUT' and self.transaction_type == 'IN':
request['es'] = self.es_transaction
request['es'] = self.transaction_es
self.handle_request(0, request_end)
else:
@@ -306,12 +306,12 @@ class Decoder(srd.Decoder):
if pname == 'SOF':
return
if self.transaction_state == 'TOKEN RECEIVED':
transaction_timeout = self.es_transaction
transaction_timeout = self.transaction_es
# Token length is 35 bits, timeout is 16..18 bit times
# (USB 2.0 7.1.19.1).
transaction_timeout += int((self.es_transaction - self.ss_transaction) / 2)
transaction_timeout += int((self.transaction_es - self.transaction_ss) / 2)
if ss > transaction_timeout:
self.es_transaction = transaction_timeout
self.transaction_es = transaction_timeout
self.handshake = 'timeout'
self.handle_transfer()
self.transaction_state = 'IDLE'
@@ -323,8 +323,8 @@ class Decoder(srd.Decoder):
sync, pid, addr, ep, crc5 = pinfo
self.transaction_data = []
self.ss_transaction = ss
self.es_transaction = es
self.transaction_ss = ss
self.transaction_es = es
self.transaction_state = 'TOKEN RECEIVED'
self.transaction_ep = ep
self.transaction_addr = addr
@@ -347,7 +347,7 @@ class Decoder(srd.Decoder):
self.handshake = pname
self.transaction_state = 'IDLE'
self.es_transaction = es
self.transaction_es = es
self.handle_transfer()
elif pname == 'PRE':

View File

@@ -55,7 +55,7 @@ class Decoder(srd.Decoder):
self._d1_prev = None
self._state = None
self.ss_state = None
self._ss_state = None
self.ss_bit = None
self.es_bit = None
@@ -98,8 +98,8 @@ class Decoder(srd.Decoder):
elif self._state == 'invalid':
ann = [1, [self._state]]
if ann:
self.put(self.ss_state, self.samplenum, self.out_ann, ann)
self.ss_state = self.samplenum
self.put(self._ss_state, self.samplenum, self.out_ann, ann)
self._ss_state = self.samplenum
self._state = state
self._bits = []

View File

@@ -18,9 +18,177 @@
##
import sigrokdecode as srd
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)
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",
]
class Decoder(srd.Decoder):
api_version = 2
@@ -36,7 +204,7 @@ class Decoder(srd.Decoder):
('fields', 'XFP structure fields'),
)
def __init__(self):
def __init__(self, **kwargs):
# Received data items, used as an index into samplenum/data
self.cnt = -1
# Start/end sample numbers per data item