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

Fixed issues causing errors in test cases using real devices #321

Merged
merged 12 commits into from
May 5, 2023
4 changes: 2 additions & 2 deletions generated/nidaqmx/_library_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4317,7 +4317,7 @@ def read_digital_lines(
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int,
ctypes.c_double, ctypes.c_int,
wrapped_ndpointer(dtype=numpy.uint8, flags=('C','W')),
wrapped_ndpointer(dtype=bool, flags=('C')),
ctypes.c_uint, ctypes.POINTER(ctypes.c_int),
ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)]

Expand Down Expand Up @@ -5783,7 +5783,7 @@ def write_digital_lines(
cfunc.argtypes = [
lib_importer.task_handle, ctypes.c_int, c_bool32,
ctypes.c_double, ctypes.c_int,
wrapped_ndpointer(dtype=numpy.uint8, flags=('C','W')),
wrapped_ndpointer(dtype=bool, flags=('C')),
ctypes.POINTER(ctypes.c_int), ctypes.POINTER(c_bool32)]

error_code = cfunc(
Expand Down
4 changes: 2 additions & 2 deletions generated/nidaqmx/_task_modules/in_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,8 @@ def read(self, number_of_samples_per_channel=READ_ALL_AVAILABLE):
numpy_array = numpy.zeros(number_of_samples, dtype=dtype)

_, samples_read, _ = self._interpreter.read_raw(
self._handle, numpy_array, num_samps_per_chan,
self.timeout)
self._handle, num_samps_per_chan,
self.timeout, numpy_array)

if samples_read != number_of_samples:
return numpy_array[:samples_read]
Expand Down
2 changes: 1 addition & 1 deletion generated/nidaqmx/stream_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ def write_one_sample_port_uint32(self, data, timeout=10):
AUTO_START_UNSET else True)

return self._interpreter.write_digital_scalar_u32(
self._handle, auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data)
self._handle, auto_start, timeout, data)


class DigitalMultiChannelWriter(ChannelWriterBase):
Expand Down
6 changes: 3 additions & 3 deletions generated/nidaqmx/system/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def get_digital_power_up_states(self, device_name):
for d, p in zip(device.do_lines, states):
power_up_states.append(
DOPowerUpState(physical_channel=d.name,
power_up_state=PowerUpStates(p.value)))
power_up_state=PowerUpStates(p)))

return power_up_states

Expand Down Expand Up @@ -346,7 +346,7 @@ def get_digital_pull_up_pull_down_states(self, device_name):
power_up_states.append(
DOResistorPowerUpState(
physical_channel=d.name,
power_up_state=ResistorState(p.value)))
power_up_state=ResistorState(p)))

return power_up_states

Expand Down Expand Up @@ -451,7 +451,7 @@ def get_analog_power_up_states(self, device_name):
power_up_states.append(
AOPowerUpState(
physical_channel=a.name,
power_up_state=p.value,
power_up_state=p,
channel_type=AOPowerUpOutputBehavior(c.value)))

return power_up_states
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/templates/_task_modules/in_stream.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ ${property_template.script_property(attribute)}\
numpy_array = numpy.zeros(number_of_samples, dtype=dtype)

_, samples_read, _ = self._interpreter.read_raw(
self._handle, numpy_array, num_samps_per_chan,
self.timeout)
self._handle, num_samps_per_chan,
self.timeout, numpy_array)

if samples_read != number_of_samples:
return numpy_array[:samples_read]
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/templates/system/system.py.mako
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ ${function_template.script_function(function_object)}
for d, p in zip(device.do_lines, states):
power_up_states.append(
DOPowerUpState(physical_channel=d.name,
power_up_state=PowerUpStates(p.value)))
power_up_state=PowerUpStates(p)))

return power_up_states

Expand Down Expand Up @@ -286,7 +286,7 @@ ${function_template.script_function(function_object)}
power_up_states.append(
DOResistorPowerUpState(
physical_channel=d.name,
power_up_state=ResistorState(p.value)))
power_up_state=ResistorState(p)))

return power_up_states

Expand Down Expand Up @@ -391,7 +391,7 @@ ${function_template.script_function(function_object)}
power_up_states.append(
AOPowerUpState(
physical_channel=a.name,
power_up_state=p.value,
power_up_state=p,
channel_type=AOPowerUpOutputBehavior(c.value)))

return power_up_states
Expand Down
11 changes: 10 additions & 1 deletion src/codegen/utilities/interpreter_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
"get_analog_power_up_states_with_output_type",
]

CTYPE_CHANGE_FUNCTIONS = ["read_digital_lines", "write_digital_lines"]


def get_interpreter_functions(metadata):
"""Converts the scrapigen metadata into a list of functions."""
Expand Down Expand Up @@ -130,7 +132,14 @@ def get_argument_types(functions_metadata):
if param.is_pointer:
argtypes.append(f"ctypes.POINTER({to_param_argtype(param)})")
else:
argtypes.append(to_param_argtype(param))
# This is special case. The ctype of these parameters is passed as bool in c call.
if (
functions_metadata.function_name in CTYPE_CHANGE_FUNCTIONS
and param.parameter_name in ("read_array", "write_array")
):
argtypes.append("wrapped_ndpointer(dtype=bool, flags=('C'))")
else:
argtypes.append(to_param_argtype(param))
return argtypes


Expand Down
2 changes: 1 addition & 1 deletion src/handwritten/stream_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ def write_one_sample_port_uint32(self, data, timeout=10):
AUTO_START_UNSET else True)

return self._interpreter.write_digital_scalar_u32(
self._handle, auto_start, timeout, FillMode.GROUP_BY_CHANNEL.value, data)
self._handle, auto_start, timeout, data)


class DigitalMultiChannelWriter(ChannelWriterBase):
Expand Down