pyecsca.sca.target.simpleserial module

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

class SimpleSerialMessage(char, data)[source]

Bases: object

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

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

SimpleSerialMessage

class SimpleSerialTarget[source]

Bases: SerialTarget, ABC

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

abstract connect()[source]

Connect to the target device.

abstract disconnect()[source]

Disconnect from the target device.

abstract read(num=0, timeout=0)[source]

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)[source]

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.