SDP Interfaces

Connection options for SDP.

SDP UART

Module for serial communication with a target device using SDP protocol.

spsdk.sdp.interfaces.uart.scan_uart(port=None, baudrate=None, timeout=None)

Scan connected serial ports.

Returns list of serial ports with devices that respond to PING command. If ‘port’ is specified, only that serial port is checked If no devices are found, return an empty list.

Parameters
  • port (Optional[str]) – name of preferred serial port, defaults to None

  • baudrate (Optional[int]) – speed of the UART interface, defaults to 56700

  • timeout (Optional[int]) – timeout in milliseconds, defaults to 5000

Return type

List[Uart]

Returns

list of interfaces responding to the PING command

class spsdk.sdp.interfaces.uart.Uart(port=None, timeout=5000, baudrate=115200)

Bases: spsdk.sdp.interfaces.base.SDPInterface

UART interface.

Initialize the UART interface.

Parameters
  • port (Optional[str]) – name of the serial port, defaults to None

  • baudrate (int) – speed of the UART interface, defaults to 115200

  • timeout (int) – read/write timeout in milliseconds, defaults to 1000

Raises

SdpConnectionError – when there is no port available

property is_opened: bool

Return True if device is open, False otherwise.

Return type

bool

open()

Open the UART interface.

Raises

SdpConnectionError – when opening device fails

Return type

None

close()

Close the UART interface.

Raises

SdpConnectionError – when closing device fails

Return type

None

info()

Return information about the UART interface.

Return type

str

Returns

information about the UART interface

Raises

SdpConnectionError – when information can not be collected from device

conf(config)

Configure device.

Parameters

config (dict) – parameters dictionary

Return type

None

read(length=None)

Read data from device.

Return type

CmdResponse

Returns

data read from device

write(packet)

Write data to the device; data might be in format of ‘CmdPacket’ or bytes.

Parameters

packet (Union[CmdPacket, bytes]) – Packet to send

Return type

None

SDP USB

Module for USB communication with a target using SDP protocol.

spsdk.sdp.interfaces.usb.scan_usb(device_id=None)

Scan connected USB devices. Return a list of all devices found.

Parameters

device_id (Optional[str]) – see USBDeviceFilter classes constructor for usb_id specification

Return type

List[RawHid]

Returns

list of matching RawHid devices

class spsdk.sdp.interfaces.usb.RawHid

Bases: spsdk.sdp.interfaces.base.SDPInterface

Base class for OS specific RAW HID Interface classes.

Initialize the USB interface object.

property name: str

Get the name of the device.

Return type

str

Returns

Name of the device.

property is_opened: bool

Indicates whether device is open.

Return type

bool

Returns

True if device is open, False otherwise.

info()

Return information about the USB interface.

Return type

str

conf(config)

Set HID report data.

Parameters

config (dict) – parameters dictionary

Return type

None

open()

Open the interface.

Raises
Return type

None

close()

Close the interface.

Raises
Return type

None

write(packet)

Write data on the OUT endpoint associated to the HID interfaces.

Parameters

packet (Union[CmdPacket, bytes]) – Data to send

Raises
Return type

None

read(length=None)

Read data on the IN endpoint associated to the HID interface.

Return type

CmdResponse

Returns

Return CmdResponse object.

Raises
static enumerate(usb_device_filter)

Get list of all connected devices which matches device_id.

Parameters

usb_device_filter (USBDeviceFilter) – USBDeviceFilter object

Return type

List[RawHid]

Returns

List of interfaces found

SDP Interface Class

Module for functionality shared across all interfaces.

spsdk.sdp.interfaces.base.Interface

alias of spsdk.sdp.interfaces.base.SDPInterface

class spsdk.sdp.interfaces.base.SDPInterface

Bases: abc.ABC

Base class for all Interface classes.

close()

Close the interface.

Return type

None

conf(config)

Configure device.

Return type

None

expect_status = True
info()

Return string containing information about the interface.

Return type

str

property is_opened: bool

Indicates whether interface is open.

Return type

bool

open()

Open the interface.

Return type

None

read(length=None)

Read data from the device.

Return type

Any

write(packet)

Write a packet to the device.

Return type

None