Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start CAN session in Subordinate Mode #273

Open
CEngelbrecht opened this issue May 30, 2020 · 1 comment
Open

Unable to start CAN session in Subordinate Mode #273

CEngelbrecht opened this issue May 30, 2020 · 1 comment

Comments

@CEngelbrecht
Copy link

Using the NI-XNET Bus Monitor, it is possible to run in Subordinate mode. This does not seem to be an option when creating a CAN session using this python library, as far as I can tell.

I would like to replicate the functionality of the NI-XNET Bus Monitor in a python script using this library, but the only way to monitor traffic when multiple XNET sessions are already running is if the Bus Monitor is in Subordinate mode. The can_lstn_only parameter does not achieve this goal. Am I missing something?

import nixnet

database_name = 'CAN'
cluster_name = 'CAN'
input_frame = 'FCC_A_CRC'
interface1 = 'CAN1'

with nixnet.FrameInQueuedSession(
        interface1,
        database_name,
        cluster_name,
        input_frame) as input_session:

    input_session.intf.can_lstn_only = True

    input_session.start()

    frames = input_session.frames.read(count)
    
    for frame in frames:
        print('Received frame:')
        print(frame)

The above code produces this error when the input_session is created:

nixnet.errors.XnetError: NI-XNET: (Hex 0xBFF6300D) You tried to open the same frame twice. This is not permitted. Solution: open each frame only once

The frame has already been opened by the LabVIEW program that is reading/writing over the interface, using the XNET database specified. Again, in the Bus Monitor this is not an issue when subordinate mode is selected. Is this not supported in this library?

  • OS: Windows 10
  • Python version: 3.6
  • NI-XNET version: 18.5

Installed packages and version

nixnet (0.3.1)
pip (9.0.3)
setuptools (39.0.1)
six (1.15.0)
xlrd (1.2.0)

@tkrebes
Copy link
Contributor

tkrebes commented Jun 9, 2020

Below is a simple example that uses subordinate mode with the NI-XNET python API.

import nixnet

interface = 'CAN1'
database_name = ':subordinate:'
count = 1

with nixnet.FrameInStreamSession(interface, database_name) as input_session:
    frames = input_session.frames.read(count, timeout=10.0)
    for frame in frames:
        print('Received frame:')
        print(frame)

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants