pyecsca.sca.target.simpleserial module

Provides an abstract target class communicating using the ChipWhisperer’s SimpleSerial protocol.

class pyecsca.sca.target.simpleserial.SimpleSerialMessage(char, data)[source]

Bases: object

A SimpleSerial message consisting of a starting character and a hexadecimal string.

char: str
data: str
static from_raw(raw)[source]
Return type:

SimpleSerialMessage

class pyecsca.sca.target.simpleserial.SimpleSerialTarget[source]

Bases: SerialTarget, ABC

A SimpleSerial-ish target, sends and receives SimpleSerial messages over a serial link.

abstract connect()

Connect to the target device.

abstract disconnect()

Disconnect from the target device.

abstract read(num=0, timeout=0)

Read upto num bytes or until timeout milliseconds from the target’s serial output.

Parameters:
  • num (int) – The number of bytes to read, 0 for all available.

  • timeout (int) – The timeout in milliseconds.

Return type:

bytes

Returns:

The bytes read.

recv_msgs(timeout)[source]

Receive SimpleSerialMessage messages, while waiting upto timeout seconds.

Parameters:

timeout (int) – How long to wait.

Return type:

Mapping[str, SimpleSerialMessage]

Returns:

The received messages with their char.

abstract write(data)

Write the data bytes to the target’s serial input.

Parameters:

data (bytes) – The data to write.

Return type:

None

send_cmd(cmd, timeout)[source]

Send a SimpleSerialMessage and receive the response messages that the command produces, within a timeout.

Parameters:
  • cmd (SimpleSerialMessage) – The command message to send.

  • timeout (int) – The timeout value to wait for the responses.

Return type:

Mapping[str, SimpleSerialMessage]

Returns:

A mapping of the starting character of the message to the message.