xcomcan.node module

StuCanPublicError.__init__(id, error_code)[source]
id : int
Service identifier
error_code : int
Error code number
StuCanPublicNode.__init__(driver, address, debug=False)[source]

Initialize CanNode

driver : PythonCanDriver
Relying can interface
address : int
Node CAN address
class xcomcan.node.MessageNotification(*args)[source]

Bases: xcomcan.node.Response

Message Notification Service inherits from Response

PACK_FORMAT = '>HI'

Format to generate a byte-string representation of the object

Type:const string
SERVICE_ID = 3

Service identifier

Type:const int
handle(source_address, destination_address, exception=None)[source]

Method override, handle response from a previously sended Service. It will handle response object and notify request service on success otherwise forward exception

messages = []

List of messages

Type:list
class xcomcan.node.ReadParameterRequest(*args)[source]

Bases: xcomcan.node.Request

Read Parameter Service request inherits from Request

PACK_FORMAT = '>HB'

Format to generate a byte-string representation of the object

Type:const string
SERVICE_ID = 1

Service identifier

Type:const int
class xcomcan.node.ReadParameterResponse(*args)[source]

Bases: xcomcan.node.Response

Read Parameter Service response inherits from Response

PACK_FORMAT = '>HBf'

Format to generate a byte-string representation of the object

Type:const string
SERVICE_ID = 1

Service identifier

Type:const int
request_class

Request service object

alias of ReadParameterRequest

class xcomcan.node.ReadUserInfoRequest(*args)[source]

Bases: xcomcan.node.Request

Read User Info Service request inherits from Request

PACK_FORMAT = '>H'

Format to generate a byte-string representation of the object

Type:const string
SERVICE_ID = 0

Service identifier

Type:const int
class xcomcan.node.ReadUserInfoResponse(*args)[source]

Bases: xcomcan.node.Response

Read User Info Service response inherits from Response

PACK_FORMAT = '>Hf'

Format to generate a byte-string representation of the object

Type:const string
SERVICE_ID = 0

Service identifier

Type:const int
request_class

Request service object

alias of ReadUserInfoRequest

class xcomcan.node.Request[source]

Bases: stucancommon.node.Service

Base class for a request service that have a condition to wait until notification from another thread

cv = <Condition(<unlocked _thread.RLock object owner=0 count=0>, 0)>
class xcomcan.node.Response[source]

Bases: stucancommon.node.Service

Base class for a response service

handle(source_address, destination_address, exception=None)[source]

Method override, handle response from a previously sended Service. It will handle response object and notify request service on success otherwise forward exception

exception xcomcan.node.StuCanPublicError(id, error_code)[source]

Bases: Exception

Class representing a StuCan2 error, also can generate a string representation of it

class xcomcan.node.StuCanPublicNode(driver, address, debug=False)[source]

Bases: stucancommon.node.CanNode

Class representing a StuCan public node, inherits from CanNode

handle_rx_frame(identifier, data, dlc, flag, time)[source]

Handle a frame received on the CAN bus

Manage behavior as described into StuCan2 public protocol

Parameters:
  • identifier (bytes) – CAN frame id
  • data (bytes) – CAN frame data
messages()[source]

Retreive the list of messages previously happened on the CAN bus

Returns:Notifications messages
Return type:list
send(service_id, destination_address, data)[source]

Forward data to send by adding source address

Parameters:
  • service_id (int) – StuCan2 service identifier
  • destination_address (int) – Targeted device address
  • data (bytes) – The data parameter of a CAN message
send_from(service_id, destination_address, source_address, data)[source]

Create CAN identifier and access underlying driver to send it and relevant data

Parameters:
  • service_id (int) – StuCan2 service identifier
  • destination_address (int) – Targeted device address
  • source_address (int) – Source address
  • data (bytes) – The data parameter of a CAN message, length from 0 to 8 bytes
send_service(address, service)[source]

Send a service

Parameters:
  • address (int) – Targeted device address
  • service (Service) – Service object
wait_response(address, request, timeout=None)[source]

Entry point to send a service and then wait for the service response, can raise a timeout exception a StuCanPublicError or the response when successfull

Parameters:
  • address (int) – Targeted device address
  • request (Request) – Request service object
Returns:

Response object of the service

Return type:

Response

class xcomcan.node.WriteParameterRequest(*args)[source]

Bases: xcomcan.node.Request

Write Parameter Service request inherits from Request

PACK_FORMAT = '>HBf'

Format to generate a byte-string representation of the object

Type:const string
SERVICE_ID = 2

Service identifier

Type:const int
class xcomcan.node.WriteParameterResponse(*args)[source]

Bases: xcomcan.node.Response

Write Parameter Service response inherits from Response

PACK_FORMAT = '>HBf'

Format to generate a byte-string representation of the object

Type:const string
SERVICE_ID = 2

Service identifier

Type:const int
request_class

Request service object

alias of WriteParameterRequest

xcomcan.node.error_identifier_dictionary = {1: 'INVALID_FRAME', 2: 'DEVICE_NOT_FOUND', 3: 'RESPONSE_TIMEOUT', 18: 'INVALID_SERVICE_ARGUMENT', 19: 'GATEWAY_BUSY', 34: 'OBJECT_ID_NOT_FOUND', 36: 'INVALID_DATA_LENGTH', 37: 'PROPERTY_IS_READ_ONLY', 38: 'INVALID_DATA', 39: 'DATA_TOO_SMALL', 40: 'DATA_TOO_BIG', 41: 'WRITE_PROPERTY_FAILED', 42: 'READ_PROPERTY_FAILED', 43: 'ACCESS_DENIED', 45: 'MULTICAST_READ_NOT_SUPPORTED'}

Those error codes applies for “User Info read service” and “Parameter read/write service”. They are coded in the response in case of a request failure.