-
Notifications
You must be signed in to change notification settings - Fork 188
Open
Labels
Description
Bug Report
I found grpc_session options in the docs and was trying to use it. I also used this example as reference.
Repro or Code Sample
"""Test file for nidaqmx"""
import logging
# https://nidaqmx-python.readthedocs.io/en/stable/
# Examples: https://github.com/ni/nidaqmx-python
import nidaqmx
from nidaqmx.task import Task as ni_task
from nidaqmx import (
constants as ni_const,
Scale as ni_scale
)
from nidaqmx.errors import Error as ni_error
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("NI-Test")
# https://github.com/ni/grpc-device/blob/main/examples/nidaqmx/analog-output.py
import grpc
SERVER_ADDRESS = "131.220.157.80"
SERVER_PORT = "31763"
# Create a gRPC channel + client.
channel = grpc.insecure_channel(f"{SERVER_ADDRESS}:{SERVER_PORT}")
grpc_options = nidaqmx.GrpcSessionOptions(
grpc_channel=grpc.insecure_channel(f"{SERVER_ADDRESS}:{SERVER_PORT}"),
session_name="grpc_test",
initialization_behavior=nidaqmx.SessionInitializationBehavior.AUTO
)
nidaqmx.system.system.System.remote(grpc_options=grpc_options)
try:
with ni_task("grpc_test", grpc_options=grpc_options ) as do_task:
# Add digital channel
do_task.do_channels.add_do_chan("Dev1/port0")
# Set output value
do_task.write(ni_const.LogicFamily.FIVE_V.value)
# Wait until tasks are done
do_task.wait_until_done()
logger.info("Test successful.")
except ni_error as e:
logger.error("NiError during grpc test: %s", e)
Expected Behavior
Connect to the gRPC server a run tasks there.
I can connect to the gRPC server if I build a client like described and run e.g. this example. However using the package from pypi is better to maintain.
Current Behavior
Error Message: ModuleNotFoundError: No module named 'session_pb2'
/home/nikongen/.venv/bin/python /home/nikongen/test/nidaq/test.py
Traceback (most recent call last):
File "/home/nikongen/test/nidaq/test.py", line 31, in <module>
nidaqmx.system.system.System.remote(grpc_options=grpc_options)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/nikongen/.venv/lib/python3.13/site-packages/nidaqmx/system/system.py", line 62, in remote
return System(grpc_options)
File "/home/nikongen/.venv/lib/python3.13/site-packages/nidaqmx/system/system.py", line 44, in __init__
self._interpreter = utils._select_interpreter(grpc_options)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/home/nikongen/.venv/lib/python3.13/site-packages/nidaqmx/utils.py", line 209, in _select_interpreter
from nidaqmx._grpc_interpreter import GrpcStubInterpreter
File "/home/nikongen/.venv/lib/python3.13/site-packages/nidaqmx/_grpc_interpreter.py", line 18, in <module>
from nidaqmx._stubs import nidaqmx_pb2 as grpc_types
File "/home/nikongen/.venv/lib/python3.13/site-packages/nidaqmx/_stubs/nidaqmx_pb2.py", line 14, in <module>
import session_pb2 as session__pb2
ModuleNotFoundError: No module named 'session_pb2'
Possible Solution
- Insert missing files
session_pb2.pyandsession_pb2.pyitonidaqmx._stubs - Document correct usage of the gRPC server with a (linux) client.
Context
I want to add a PCIe-6323 to our existing experiment control. The card is installed in a dedicated computer running Ubuntu 24.04 with a gRPC server.
Your Environment
- Operating system and version: PopOS! 24.04
- NI-DAQmx version: None
nidaqmx-pythonversion: tested 1.3.0 and 1.4.0- Python version 3.13
- grpc-stubs==1.53.0.6
- grpcio==1.76.0
- grpcio-tools==1.76.0