IOControl

class canlib.canlib.IOControl(channel)[source]

Helper object for using canIoCtl

Provides a variety of functionality, some of which are represented as attributes of this object and some as functions. See the respective entries below for more information.

Variables
  • brlimit – An int with the hardware bitrate limit, or zero for the device’s default. Write-only.

  • bus_type – A member of the BusTypeGroup enum. Not implemented in Linux. Read-only.

  • buson_time_auto_reset – A bool for whether the CAN clock is reset at bus-on. Not implemented in Linux. Write-only.

  • channel_quality – An int between 0 and 100 (inclusively) with the quality of the channel in percent. Not implemented in Linux. Read-only.

  • devname_ascii – A str with the current device name. Not implemented in Linux. Read-only.

  • driverhandle – The windows handle related to the CANlib handle. Not implemented in Linux. Read-only.

  • error_frames_reporting – A bool for whether error frames are reported. Not implemented in Linux. Write-only.

  • eventhandle – An int with the windows event handle. Not implemented in Linux. Read-only.

  • local_txecho – A bool for whether local transmit echo is turned on. Write-only.

  • report_access_errors – A bool for whether Access Reporting is turned on

  • roundtrip_time – An int with the roundtrip time in milliseconds. Not implemented in Linux. Read-only.

  • rx_buffer_level – An int with the approximate receive queue level. Read-only.

  • rx_queue_size – An int with the size of the receive buffer. Can only be used off-bus. Not implemented in Linux. Write-only.

  • throttle_scaled – An int between 0 and 100 (inclusively) where 0 means the device is very responsive but generates more CPU load and 100 means the device is less responsive with less CPU load. Note that not all devices support setting this. Some hardware will accept this command but neglect it. Not implemented in Linux.

  • time_since_last_seen – An int with the time in milliseconds since the last communication occured. Not implemented in Linux. Read-only.

  • timer_scale – An int with the time-stamp clock resolution in microseconds. Used e.g. in Channel.read(). Default is 1000, i.e. 1 ms.

  • tx_buffer_level – An int with the approximate transmit queue level. Read-only.

  • tx_interval – An int with the number of microseconds with the minimum CAN message transmit interval.

  • txack – 0 for Transmit Acknowledges off, 1 for Transmit Acknowledges on, and 2 for Transmit Acknowledges off, even for the driver’s internal usage (this will break parts of the library).

  • txrq – A bool for whether Transmit Requests are turned on. Write-only.

clear_error_counters()

Tells CANlib to clear the CAN error counters. CAN error counters on device side are NOT updated. It is recommended to use reset_overrun_count to reset overrun status. Not implemented in Linux.

connect_to_virtual_bus(value)

Connects the channel to the virtual bus number value.

disconnect_from_virtual_bus(value)

Disconnects the channel from the virtual bus number value.

flush_rx_buffer()

Discard the current contents of the RX queue.

flush_tx_buffer()

Discard the current contents of the TX queue.

prefer_ext()

Tells CANlib to assume MessageFlag.EXT when sending messages if neither MessageFlag.EXT or MessageFlag.STD is specified. Not implemented in Linux.

prefer_std()

Tells CANlib to assume MessageFlag.STD when sending messages if neither MessageFlag.EXT or MessageFlag.STD is specified. Not implemented in Linux.

reset_overrun_count()

Resets overrun count and flags.

raw(item, value=None, ctype=<class 'ctypes.c_uint'>)[source]

A raw call to canIoCtl

Parameters
  • item (IOControlItem) – The “function code” to be passed to canIoCtl.

  • value – The value sent to canIoCtl or None if no value should be given. Must be compatible with the ctype argument.

  • ctype – The ctypes type that should be used to when sending the value argument and when interpreting the result of canIoCtl.