Class strym

Import strym as:

from strym import strym

for real-time visualization of CAN data when comma.ai Panda devices is plugged to system via USB. Currently deprecated in favor of libpanda.

class strym.strym(dbcfile, **kwargs)

strym class records data from Comm AI Panda and visualize in real time. The constructor first gets an “USB context” by creating USBContext instance. Then, it browses available USB devices and open the one whose manufacturer is COMMA.AI. One right device is identified, strym creates a device handle, enables automatic kernel driver detachment and claim interface for I/O operation.

Read and Write for USB devices are either done synchronosly or in isochronos mode.

If your interest is merely in capturing data, you should perform synchronous mode.

For (almost) real time visualization, isochronous mode is the way to go.

Parameters
dbcfile : string

path of can database file in order to decode the message : Provide

kwargs

Arbitrary keyword arguments.

path: string

Specify the path/folder where data will be saved. By default path is set to ~/CyverseData/JmscslgroupData/PandaData

isolog(visualize, msg_type, attribute_num, **kwargs)

isoviz() function will log everything in asynchronous manner but only visualize specific attribute of the given message. Upon pressing ctrl-C, the logging will terminate and SIGINT signal handler will create a plot and save in two formats: python’s pickle format and pdf.

isoviz is responsible handling data transfer in the isochronous mode and parsing through callback function process_received_data

See https://vovkos.github.io/doxyrest/samples/libusb/group_libusb_asyncio.html?highlight=transfer#details-group-libusb-asyncio for more detail

Parameters
visualize : bool

specifies whether to visaulize while logging the CAN data

msg_type : string

specifies a valid message type from the DBC file

attribute_num : int

select the specific attribute from the given mgs_type to be displayed

**kwargs

Arbitrary keyword arguments.

log: enumeration: {info, debug}

set log level to info and debug

match: enumeration: {exact, in}

how the message type and specified attribute should be matched for visualization. exact specifies exact match, in specifies substring matching.

kill(sig)

kill catches SIGINT or CTRL-C while recording the data and closes the comma ai device connection

parse_can_buffer(dat)

parse_can_buffer parses the can data received through the USB device and returns list of message ID, message and bus number

Parameters
dat : bytearray

byte data to be parsed

Returns

list – Returns a list containing message ID, message and bus number

process_received_data(transfer)

process_received_data function implements a callback that processes the reeceived data from USB in isochronous mode. Once data is extracted from buffer, it is saved in the object’s data variable. The data is used to update the plot in the real time.