Skip to content

Commit

Permalink
Update minimal
Browse files Browse the repository at this point in the history
  • Loading branch information
ChipWhisperer-Bot committed Aug 14, 2024
1 parent f9f814a commit 01d535a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 181 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ Stuck? If you need a hand, there are a few places you can ask for help:
---

ChipWhisperer is a trademark of NewAE Technology Inc., registered in the US, Europe, and China.

64 changes: 0 additions & 64 deletions chipwhisperer/capture/targets/SimpleSerial2.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,34 +630,6 @@ def write(self, data, timeout=0):
data = bytearray(data)
self.ser.write(data, timeout)

@property
def parity(self):
if hasattr(self.ser, 'parity') and callable(self.ser.parity):
return self.ser.parity()
else:
raise AttributeError("Can't access parity")

@parity.setter
def parity(self, parity):
if hasattr(self.ser, 'parity') and callable(self.ser.parity):
return self.ser.setParity(parity)
else:
raise AttributeError("Can't access parity")

@property
def stop_bits(self):
if hasattr(self.ser, 'stopBits') and callable(self.ser.stopBits):
return self.ser.stopBits()
else:
raise AttributeError("Can't access parity")

@stop_bits.setter
def stop_bits(self, stop_bits):
if hasattr(self.ser, 'stopBits') and callable(self.ser.stopBits):
return self.ser.setStopBits(stop_bits)
else:
raise AttributeError("Can't access parity")

@property
def baud(self):
"""The current baud rate of the serial connection.
Expand Down Expand Up @@ -733,42 +705,6 @@ def in_waiting_tx(self):
"""
return self.ser.inWaitingTX()

@property
def xonxoff(self):
# TODO: check version to make sure fw has this
return self.ser.xonxoff

@xonxoff.setter
def xonxoff(self, enable):
self.ser.xonxoff = enable

@property
def currently_xoff(self):
return self.ser.currently_xoff

def __repr__(self):
ret = "SimpleSerial Settings ="
for line in dict_to_str(self._dict_repr()).split("\n"):
ret += "\n\t" + line
return ret

def __str__(self):
return self.__repr__()

def _dict_repr(self):
rtn = OrderedDict()
rtn['output_len'] = self.output_len

rtn['baud'] = self.baud
rtn['simpleserial_last_read'] = self.simpleserial_last_read
rtn['simpleserial_last_sent'] = self.simpleserial_last_sent
rtn['xonxoff'] = self.xonxoff
rtn['currently_xoff'] = self.currently_xoff
rtn['parity'] = self.parity
rtn['stop_bits'] = self.stop_bits
#rtn['protver'] = self.protver
return rtn

class SimpleSerial2_CDC(SimpleSerial2):
"""Target Option for Using SSV2 with a CDC Port
Expand Down
52 changes: 3 additions & 49 deletions chipwhisperer/capture/targets/simpleserial_readers/cwlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class SimpleSerial_ChipWhispererLite(SimpleSerialTemplate):
def __init__(self):
SimpleSerialTemplate.__init__(self)
self._baud = 38400
self._parity = "none"
self._stopbits = 1
self.cwlite_usart = None
self._buf_size = None

Expand All @@ -45,48 +43,17 @@ def close(self):
def setBaud(self, baud):
self._baud = baud
if self.cwlite_usart:
self.cwlite_usart.init(self._baud, self._stopbits, self._parity)
self.cwlite_usart.init(baud)
else:
logging.error('Baud rate not set, need to connect first')

def baud(self):
return self._baud

def setParity(self, parity):
old = self._parity
try:
self._parity = parity
if self.cwlite_usart:
self.cwlite_usart.init(self._baud, self._stopbits, self._parity)
else:
logging.error('Baud rate not set, need to connect first')
except ValueError as e:
self._parity = old
raise e

def parity(self):
return self._parity

def setStopBits(self, stopbits):
old = self._stopbits
try:
self._stopbits = stopbits
if self.cwlite_usart:
self.cwlite_usart.init(self._baud, self._stopbits, self._parity)
else:
logging.error('Baud rate not set, need to connect first')
except ValueError as e:
self._stopbits = old
raise e

def stopBits(self):
return self._stopbits


def con(self, scope): # remove typing here to avoid pulling in OpenADC/CWNano
if not scope is None:
self.cwlite_usart = scope._get_usart()
self.cwlite_usart.init(baud=self._baud, stopbits=self._stopbits, parity=self._parity)
self.cwlite_usart.init(baud=self._baud)
self._buf_size = 128
if self.cwlite_usart._usb.check_feature("SERIAL_200_BUFFER"):
self._buf_size = 200
Expand All @@ -106,17 +73,4 @@ def hardware_write(self, string):
self.cwlite_usart.write(string)

def hardware_read(self, num, timeout=250):
return self.cwlite_usart.read(num, timeout)

@property
def xonxoff(self):
# TODO: check version to make sure fw has this
return self.cwlite_usart.xonxoff

@xonxoff.setter
def xonxoff(self, enable):
self.cwlite_usart.xonxoff = enable

@property
def currently_xoff(self):
return self.cwlite_usart.currently_xoff
return self.cwlite_usart.read(num, timeout)
10 changes: 5 additions & 5 deletions chipwhisperer/hardware/firmware/cw1200.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chipwhisperer/hardware/firmware/cwhusky.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chipwhisperer/hardware/firmware/cwlite.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions chipwhisperer/hardware/naeusb/naeusb.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
"MPSSE_ENABLED", #15
"HUSKY_PIN_CONTROL", #16
"NANO_CLOCK_RESET", #17
"SAM_ERR_LED", #18
"XON_XOFF", #19
"SAM_ERR_LED" #18
]

class CWFirmwareError(Exception):
Expand Down Expand Up @@ -152,8 +151,7 @@ class CWFirmwareError(Exception):
SAM_FW_FEATURES[10]: '1.0.0',
SAM_FW_FEATURES[11]: '1.0.0',
SAM_FW_FEATURES[12]: '1.1.0',
SAM_FW_FEATURES[13]: '1.2.0',
SAM_FW_FEATURES[19]: '1.4.0',
SAM_FW_FEATURES[13]: '1.2.0'
},

0xC340: {
Expand Down
75 changes: 21 additions & 54 deletions chipwhisperer/hardware/naeusb/serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class USART(object):
USART_CMD_DISABLE = 0x0012
USART_CMD_NUMWAIT = 0x0014
USART_CMD_NUMWAIT_TX = 0x0018
USART_CMD_XONXOFF = 0x0020

def __init__(self, usb, timeout=200, usart_num=0):
"""
Expand Down Expand Up @@ -75,40 +74,27 @@ def init(self, baud=115200, stopbits=1, parity="none"):
self._stopbits = stopbits
self._parity = parity

valid_stopbits = [1, 1.5, 2]
valid_parity = ["none", "odd", "even", "mark", "space"]
try:
stopbits = valid_stopbits.index(stopbits)
except ValueError:
raise ValueError("Invalid stop-bit {}, must be one of {}".format(stopbits, valid_stopbits))

try:
parity = valid_parity.index(parity)
except ValueError:
raise ValueError("Invalid parity {}, must be one of {}".format(parity, valid_parity))


# if stopbits == 1:
# stopbits = 0
# elif stopbits == 1.5:
# stopbits = 1
# elif stopbits == 2:
# stopbits = 2
# else:
# raise ValueError("Invalid stop-bit spec: %s" % str(stopbits))

# if parity == "none":
# parity = 0
# elif parity == "odd":
# parity = 1
# elif parity == "even":
# parity = 2
# elif parity == "mark":
# parity = 3
# elif parity == "space":
# parity = 4
# else:
# raise ValueError("Invalid parity spec: %s" % str(parity))
if stopbits == 1:
stopbits = 0
elif stopbits == 1.5:
stopbits = 1
elif stopbits == 2:
stopbits = 2
else:
raise ValueError("Invalid stop-bit spec: %s" % str(stopbits))

if parity == "none":
parity = 0
elif parity == "odd":
parity = 1
elif parity == "even":
parity = 2
elif parity == "mark":
parity = 3
elif parity == "space":
parity = 4
else:
raise ValueError("Invalid parity spec: %s" % str(parity))

cmdbuf = bytearray(7)
util.pack_u32_into(cmdbuf, 0, int(baud))
Expand Down Expand Up @@ -280,22 +266,3 @@ def fw_version_str(self):
if not self.fw_read:
self.fw_read = self._usb.readFwVersion()
return "{}.{}.{}".format(self.fw_read[0], self.fw_read[1], self.fw_read[2])

@property
def xonxoff(self):
# TODO: check version to make sure fw has this
if self._usb.check_feature("XON_XOFF"):
return self._usartRxCmd(self.USART_CMD_XONXOFF)[0] & 0x01
return None

@xonxoff.setter
def xonxoff(self, enable):
if self._usb.check_feature("XON_XOFF"):
enable = 1 if enable else 0
self._usartTxCmd(self.USART_CMD_XONXOFF, [enable])

@property
def currently_xoff(self):
if self._usb.check_feature("XON_XOFF"):
return self._usartRxCmd(self.USART_CMD_XONXOFF)[0] & 0x02
return None

0 comments on commit 01d535a

Please sign in to comment.