PCP_over_USB
PCP (Pulsar Communication Protocol) adapter for USB connections.
This class provides USB serial communication for the PCP protocol, sending messages, receiving incoming messages in a thread for asynchronous communication
Source code in pcp_api/pcp_over_usb.pyi
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
is_connected
property
Check if the USB connection is active.
Returns:
Type | Description |
---|---|
bool
|
True if connected, False otherwise |
__init__(port=None, connect_on_init=True, logger=None)
Initialize PCP over USB communication adapter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
Optional[str]
|
Serial port name (e.g., 'COM3', '/dev/ttyACM0'). If None, auto-discovery is attempted. |
None
|
connect_on_init
|
bool
|
Whether to automatically connect during initialization |
True
|
logger
|
Optional[Logger]
|
Optional logger for debugging messages |
None
|
Source code in pcp_api/pcp_over_usb.pyi
close()
connect(port=None)
Establish a connection to the device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
str
|
Serial port name. If None, uses previously set port or auto-discovery. |
None
|
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if connection successful, False otherwise |
Source code in pcp_api/pcp_over_usb.pyi
disconnect()
Disconnect from the USB serial port and stop background threads.
Cleanly shuts down the polling thread and closes the serial connection.
get_port()
staticmethod
Auto-discover a single USB serial port for PCP communication.
Attempts to automatically find a suitable serial port. If exactly one Pulsar HRI port is found, returns it. Otherwise, returns empty string.
Returns:
Type | Description |
---|---|
str
|
Serial port name if exactly one suitable port is found, empty string otherwise |
Source code in pcp_api/pcp_over_usb.pyi
get_ports()
staticmethod
Get list of available USB serial ports from Pulsar HRI devices.
Automatically filters serial ports to only include those manufactured by Pulsar HRI, which are compatible with PCP over USB.
Returns:
Type | Description |
---|---|
List[str]
|
List of serial port names/paths (e.g., ['COM3', 'COM5'] on Windows |
List[str]
|
or ['/dev/ttyACM0', '/dev/ttyACM1'] on Linux) |
Source code in pcp_api/pcp_over_usb.pyi
send_PCP(address, data)
Send a PCP message to the specified address.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
int
|
Target PCP address (1-16382) |
required |
data
|
List[int]
|
List of bytes to send as message payload |
required |
Returns:
Type | Description |
---|---|
bool
|
True if message was sent successfully, False otherwise |
Source code in pcp_api/pcp_over_usb.pyi
setCallback(address, callback)
Register a callback function for messages from a specific PCP address.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
address
|
int
|
PCP address to listen for (1-16382) |
required |
callback
|
Callable[[int, List[int]], None]
|
Function to call when messages are received from this address. Callback signature: callback(address: int, data: List[int]) |
required |