Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

* ### Major Changes
* Add support for Analog Path Delay
* Added `nitlsconfig[grpc]>=1.0.0a4` to the optional gRPC dependencies.

Check warning on line 41 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 41 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)
Comment thread
alexdubois-ni marked this conversation as resolved.
Outdated

* ### Known Issues
* ...
Expand Down
51 changes: 31 additions & 20 deletions generated/nidaqmx/_grpc_interpreter.py
Comment thread
alexdubois-ni marked this conversation as resolved.
Comment thread
alexdubois-ni marked this conversation as resolved.
Comment thread
bkeryan marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import google.protobuf.message
import grpc
import nitlsconfig

Check warning on line 15 in generated/nidaqmx/_grpc_interpreter.py

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 15 in generated/nidaqmx/_grpc_interpreter.py

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)
import numpy

from . import errors as errors
Expand Down Expand Up @@ -101,14 +102,20 @@
def __init__(self, grpc_options):
self._grpc_options = grpc_options
self._client = nidaqmx_grpc.NiDAQmxStub(grpc_options.grpc_channel)
# Querying the driver version is the first contact with the server, so it decides
# whether this interpreter connected.
connected = False
try:
major_version = self.get_system_info_attribute_uint32(0x1272)
minor_version = self.get_system_info_attribute_uint32(0x1923)
update_version = self.get_system_info_attribute_uint32(0x2f22)
connected = True
except Exception:
major_version = 0
minor_version = 0
update_version = 0
finally:
nitlsconfig.audit_session_connect('NI-DAQmx', grpc_options.grpc_channel, connected)

Check warning on line 118 in generated/nidaqmx/_grpc_interpreter.py

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 118 in generated/nidaqmx/_grpc_interpreter.py

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)
self._driver_version = DriverVersion(major_version, minor_version, update_version)

def _invoke(self, func, request, metadata=None):
Expand Down Expand Up @@ -141,7 +148,11 @@
error_message += f'\nSamples per channel written: {entry.value}'
grpc_error = rpc_error.code()
if grpc_error == grpc.StatusCode.UNAVAILABLE:
error_message = 'Failed to connect to server'
# gRPC reports a rejected TLS handshake and an unreachable server with the
# same code, so ask NI-TLS whether it built this channel and can say more.
error_message = nitlsconfig.get_tls_connection_error_elaboration(

Check warning on line 153 in generated/nidaqmx/_grpc_interpreter.py

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 153 in generated/nidaqmx/_grpc_interpreter.py

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)
self._grpc_options.grpc_channel
) or 'Failed to connect to server'
elif grpc_error == grpc.StatusCode.UNIMPLEMENTED:
error_message = (
'This operation is not supported by the NI gRPC Device Server being used. Upgrade NI gRPC Device Server.'
Expand Down Expand Up @@ -2427,7 +2438,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

Comment thread
alexdubois-ni marked this conversation as resolved.
Outdated
_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2447,7 +2458,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2461,7 +2472,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2475,7 +2486,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2489,7 +2500,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2501,7 +2512,7 @@
grpc_types.ReadCounterF64Request(
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2515,7 +2526,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2539,7 +2550,7 @@
grpc_types.ReadCounterU32Request(
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2553,7 +2564,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2569,7 +2580,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, interleaved_raw=interleaved,
array_size_in_samps=read_array_frequency.size))

_assign_numpy_array(read_array_frequency, response.read_array_frequency)
_assign_numpy_array(read_array_duty_cycle, response.read_array_duty_cycle)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
Expand All @@ -2592,7 +2603,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, interleaved_raw=interleaved,
array_size_in_samps=read_array_high_ticks.size))

_assign_numpy_array(read_array_high_ticks, response.read_array_high_ticks)
_assign_numpy_array(read_array_low_ticks, response.read_array_low_ticks)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
Expand All @@ -2615,7 +2626,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, interleaved_raw=interleaved,
array_size_in_samps=read_array_high_time.size))

_assign_numpy_array(read_array_high_time, response.read_array_high_time)
_assign_numpy_array(read_array_low_time, response.read_array_low_time)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
Expand All @@ -2636,7 +2647,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_bytes=read_array.nbytes))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read, response.num_bytes_per_samp
Expand All @@ -2656,7 +2667,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2670,7 +2681,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.size))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2684,7 +2695,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array.nbytes))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
return read_array, response.samps_per_chan_read
Expand All @@ -2700,7 +2711,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array_voltage.size))

_assign_numpy_array(read_array_voltage, response.read_array_voltage)
_assign_numpy_array(read_array_current, response.read_array_current)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
Expand All @@ -2717,7 +2728,7 @@
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, fill_mode_raw=fill_mode,
array_size_in_samps=read_array_voltage.size))

_assign_numpy_array(read_array_voltage, response.read_array_voltage)
_assign_numpy_array(read_array_current, response.read_array_current)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_per_chan_read)
Expand All @@ -2736,7 +2747,7 @@
grpc_types.ReadRawRequest(
task=task, num_samps_per_chan=num_samps_per_chan,
timeout=timeout, array_size_in_bytes=read_array.nbytes))

_assign_numpy_array(read_array, response.read_array)
self._check_for_error_from_response(response.status, samps_per_chan_read=response.samps_read)
return read_array, response.samps_read, response.num_bytes_per_samp
Expand Down
56 changes: 54 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ min-release-age-exclude = [
"ni-grpcdevice-v1-proto",
"ni-protobuf-types",
"ni-python-styleguide",
"nitlsconfig",
"nitypes",
]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
nidaqmx = 'nidaqmx.__main__:main'

[project.optional-dependencies]
grpc = ['grpcio (>=1.49.0,<2.0)', 'protobuf (>=4.21)', 'ni-grpcdevice-v1-proto (>=1.0.0)', 'ni-protobuf-types (>=1.0.0)']
grpc = ['grpcio (>=1.49.0,<2.0)', 'protobuf (>=4.21)', 'ni-grpcdevice-v1-proto (>=1.0.0)', 'ni-protobuf-types (>=1.0.0)', 'nitlsconfig[grpc] (>=1.0.0a4)']

Check warning on line 46 in pyproject.toml

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 46 in pyproject.toml

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)

[tool.poetry]

Expand Down
13 changes: 12 additions & 1 deletion src/codegen/templates/_grpc_interpreter.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import google.protobuf.message
import grpc
import nitlsconfig

Check warning on line 32 in src/codegen/templates/_grpc_interpreter.py.mako

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 32 in src/codegen/templates/_grpc_interpreter.py.mako

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)
import numpy

from . import errors as errors
Expand Down Expand Up @@ -118,14 +119,20 @@
def __init__(self, grpc_options):
self._grpc_options = grpc_options
self._client = nidaqmx_grpc.NiDAQmxStub(grpc_options.grpc_channel)
# Querying the driver version is the first contact with the server, so it decides
# whether this interpreter connected.
connected = False
try:
major_version = self.get_system_info_attribute_uint32(0x1272)
minor_version = self.get_system_info_attribute_uint32(0x1923)
update_version = self.get_system_info_attribute_uint32(0x2f22)
connected = True
Comment thread
alexdubois-ni marked this conversation as resolved.
except Exception:
major_version = 0
minor_version = 0
update_version = 0
finally:
nitlsconfig.audit_session_connect('NI-DAQmx', grpc_options.grpc_channel, connected)

Check warning on line 135 in src/codegen/templates/_grpc_interpreter.py.mako

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 135 in src/codegen/templates/_grpc_interpreter.py.mako

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)
Comment thread
alexdubois-ni marked this conversation as resolved.
self._driver_version = DriverVersion(major_version, minor_version, update_version)

def _invoke(self, func, request, metadata=None):
Expand Down Expand Up @@ -158,7 +165,11 @@
error_message += f'\nSamples per channel written: {entry.value}'
grpc_error = rpc_error.code()
if grpc_error == grpc.StatusCode.UNAVAILABLE:
error_message = 'Failed to connect to server'
# gRPC reports a rejected TLS handshake and an unreachable server with the
# same code, so ask NI-TLS whether it built this channel and can say more.
error_message = nitlsconfig.get_tls_connection_error_elaboration(

Check warning on line 170 in src/codegen/templates/_grpc_interpreter.py.mako

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.14)

Unknown word (nitlsconfig)

Check warning on line 170 in src/codegen/templates/_grpc_interpreter.py.mako

View workflow job for this annotation

GitHub Actions / Run CI / Build / Build (ubuntu-latest, 3.9)

Unknown word (nitlsconfig)
self._grpc_options.grpc_channel
) or 'Failed to connect to server'
elif grpc_error == grpc.StatusCode.UNIMPLEMENTED:
error_message = (
'This operation is not supported by the NI gRPC Device Server being used. Upgrade NI gRPC Device Server.'
Expand Down
Loading
Loading