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 Nonebaudrate (
Optional
[int
]) – speed of the UART interface, defaults to 56700timeout (
Optional
[int
]) – timeout in milliseconds, defaults to 5000
- Return type
List
[Interface
]- 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.Interface
UART interface.
Initialize the UART interface.
- Parameters
port (
Optional
[str
]) – name of the serial port, defaults to Nonebaudrate (
int
) – speed of the UART interface, defaults to 115200timeout (
int
) – read/write timeout in milliseconds, defaults to 1000
- Raises
SdpConnectionError – when there is no port available
-
property
is_opened
¶ Return True if device is open, False othervise.
- 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
- Returns
data read from device
SDP USB¶
Module for USB communication with a terget using SDP protocol.
-
spsdk.sdp.interfaces.usb.
scan_usb
(device_name=None)¶ Scan connected USB devices. Return a list of all devices found.
- Parameters
device_name (
Optional
[str
]) – see USBDeviceFilter classes constructor for usb_id specification- Return type
Sequence
[Interface
]- Returns
list of matching RawHid devices
-
class
spsdk.sdp.interfaces.usb.
RawHid
¶ Bases:
spsdk.sdp.interfaces.base.Interface
Base class for OS specific RAW HID Interface classes.
Initialize the USB interface object.
-
property
name
¶ Get the name of the device.
- Return type
str
- Returns
Name of the device.
-
property
is_opened
¶ Indicates whether device is open.
- Return type
bool
- Returns
True if device is open, False othervise.
-
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
SdpConnectionError – when there is no available device
SdpConnectionError – when the device can not be opened
- Return type
None
-
close
()¶ Close the interface.
- Raises
SdpConnectionError – when there is no device available
SdpConnectionError – when the device can not be closed
- 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
SdpError – Raises an error if packet type is incorrect
SdpConnectionError – Raises an error if device is openned for writing
SdpConnectionError – Raises if device is not available
SdpConnectionError – Raises if writing to device fails
- Return type
None
-
read
(length=None)¶ Read data on the IN endpoint associated to the HID interface.
- Return type
- Returns
Return CmdResponse object.
- Raises
SdpConnectionError – Raises an error if device is openned for reading
SdpConnectionError – Raises an error if device is not available
SdpConnectionError – Raises an error if data can not be read from device
-
static
enumerate
(usb_device_filter)¶ Get list of all connected devices which matches device_id.
- Parameters
usb_device_filter (
USBDeviceFilter
) – USBDeviceFilter object- Return type
Sequence
[Interface
]- Returns
List of interfaces found
-
property
SDP Interface Class¶
Module for functionality shared accross all interfaces.
-
class
spsdk.sdp.interfaces.base.
Interface
¶ 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
¶ 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
-