Python and NI

Showing results for 
Search instead for 
Did you mean: 

Issue with nixnet python driver

Hi everyone,


I'm trying to make a simple Python script to log CAN frames using NI-XNET driver and a USB-8502 CAN module.

I wrote a some code to display all the CAN frames transiting on the bus.


import nixnet
from nixnet import system
from nixnet import constants
from nixnet import types
import time

# Get CAN interface name
can_interfaces = nixnet.system.System().intf_refs_can

can_list = []
for can_interface in can_interfaces:

can_interface = can_list[0]

can_database = ':can_fd_brs:'
can_cluster = ''
with nixnet.FrameInStreamSession(str(can_interface), str(can_database), str(can_cluster)) as input_session:
    input_session.intf.can_term = constants.CanTerm.OFF
    input_session.intf.baud_rate = 1000000
    input_session.intf.can_fd_baud_rate = 4000000


    for i in range(0, 10):
        frames =, constants.TIMEOUT_NONE)
        for frame in frames:


When I execute this code, I have the following error :


Traceback (most recent call last):
  File "D:\my_path\", line 27, in <module>
  File "D:\Programs\Python\Python39\lib\site-packages\nixnet\_session\", line 165, in start
    _funcs.nx_start(self._handle, scope)
  File "D:\Programs\Python\Python39\lib\site-packages\nixnet\", line 395, in nx_start
  File "D:\Programs\Python\Python39\lib\site-packages\nixnet\", line 18, in check_for_error
    status = status_to_string(error_code)
  File "D:\Programs\Python\Python39\lib\site-packages\nixnet\", line 33, in status_to_string
    status_string = buffer_ctypes.value.decode("ascii")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 31: ordinal not in range(128)


If I don't specify database and cluster in the FrameInStreamSession() call, I do not have error, but by default the configuration is CAN, not CAN FD + BRS.


Is this a known issue, and does anybody know how to solve this problem ?


I'm using Python 3.9.12 and nixnet 0.3.2.


Thanks to all for the support


Kind regards

0 Kudos
Message 1 of 1