Mixing an nidmm PXI-407x session and niswitch sessions causes unexpected failures finding the NI-SWITCH Functions on Linux
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 30/100
Direção de pesquisa
Comece com a sequência reproduzida na issue usando Python 3.9/Linux e, em seguida, inspecione niswitch/_library.py, niswitch/_library_interpreter.py e o caminho de inicialização da sessão mostrado no traceback. Compare como o carregamento de NI-DMM ou NI-CPower antes de NI-SWITCH afeta a busca de símbolos. O trabalho estará concluído quando o reprodutor puder abrir ambas as sessões simuladas após dmm_session.initiate() sem o enganoso DriverTooOldError.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Description of issue
Using Python 3.9.15, NI-DMM 23.5 and the nidmm 1.4.5 python package, I get weird behavior when using a 407x device and mixing usage of NI-DMM and NI-SWITCH sessions (used the niswitch 1.4.5 package, but I also reproduced with the nidcpower 1.4.5 package).
Specifically after running a very small program (listed below in the steps to reproduce) that includes opening an NI-DMM session, calling dmm.initiate(), and then opening an NI-SWITCH Session, I get the following error:
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/site-packages/niswitch/_library.py", line 65, in _get_library_function
function = getattr(self._library, name)
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/ctypes/__init__.py", line 387, in __getattr__
func = self.__getitem__(name)
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/ctypes/__init__.py", line 392, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/user/.pyenv/versions/3.9.15/bin/python: undefined symbol: niSwitch_InitWithTopology
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/user/./switch_reproducer.py", line 6, in <module>
with niswitch.Session(resource_name="", topology="2535/1-Wire 4x136 Matrix", simulate=True) as session1:
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/site-packages/niswitch/session.py", line 1377, in __init__
self._interpreter.set_session_handle(self._init_with_topology(resource_name, topology, simulate, reset_device))
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/site-packages/niswitch/session.py", line 1993, in _init_with_topology
vi = self._interpreter.init_with_topology(resource_name, topology, simulate, reset_device)
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/site-packages/niswitch/_library_interpreter.py", line 293, in init_with_topology
error_code = self._library.niSwitch_InitWithTopology(resource_name_ctype, topology_ctype, simulate_ctype, reset_device_ctype, None if vi_ctype is None else (ctypes.pointer(vi_ctype)))
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/site-packages/niswitch/_library.py", line 225, in niSwitch_InitWithTopology
self.niSwitch_InitWithTopology_cfunc = self._get_library_function('niSwitch_InitWithTopology')
File "/home/user/.pyenv/versions/3.9.15/lib/python3.9/site-packages/niswitch/_library.py", line 67, in _get_library_function
raise errors.DriverTooOldError() from e
niswitch.errors.DriverTooOldError: A function was not found in the NI-SWITCH runtime. Please visit http://www.ni.com/downloads/drivers/ to download a newer version and install it.
The error is clearly misleading. I shouldn't have any issues opening a session to both devices.
I am using IVI simulated devices, so no hardware is required.
If I simulate a 4081 DMM instead of a 4071, the error doesn't happen.
If I remove the dmm.initiate() call then the error doesn't happen.
If I use Python 3.10.8 then even the reproducing example as written doesn't reproduce.
I have also rewritten the example using a simulated nidcpower.Session (using a 4190), and that DOES reproduce (so I think that nidmm must be at fault).
I have found that this is very particular, and if I modify the code slightly I can stop seeing the error (move the dmm.initiate() after opening the niswitch.Session and its fine).
System report
python -c "import nidmm; nidmm.print_diagnostic_information()" output:
OS:
Name: Linux
Version: #26~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jul 13 16:27:29 UTC 2
Bits: 64
Driver:
Name: NI-DMM
Version: Unknown
Module:
Name: nidmm
Version: 1.4.5
Python:
Version: 3.9.15 (main, Aug 11 2023, 09:46:20)
[GCC 11.4.0]
Bits: 64
Is_Venv: False
Installed Packages:
virtualenv==20.24.2
setuptools==58.1.0
platformdirs==3.10.0
pip==22.0.4
niswitch==1.4.5
nidmm==1.4.5
nidcpower==1.4.5
hightime==0.2.1
filelock==3.12.2
distlib==0.3.7
Steps to reproduce issue
import niswitch
import nidmm
with nidmm.Session(resource_name="", options= { "simulate": True, "driver_setup": { "Model": "4071" } }) as dmm_session:
dmm_session.initiate()
with niswitch.Session(resource_name="", topology="2535/1-Wire 4x136 Matrix", simulate=True) as session1:
pass
Run the above code using python 3.9.15 on Linux
- Linguagem predominante
- Python
- Estrelas
- 129
- Forks
- 110
- Merge médio
- 4d 3h
- PRs com merge (30d)
- 1
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de ni/nimi-python
-
docs nitclk priority-low
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 68/100
ni/nimi-python#1993 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
ni/nimi-python#2164 · 1 comentário ·
-
bug docs
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 48/100
ni/nimi-python#2162 ·
-
codegen enhancement
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 42/100
ni/nimi-python#2148 · 2 comentários ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
ni/nimi-python#2122 ·
Todas as issues de ni/nimi-python
Issues semelhantes
-
[Bug] @deck.gl/arcgis dist import resolves to unpublished @deck.gl/core source path (9.3.11, 9.4.0)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
workflow: a tick's dispatch counts as 'only this step', and no review self-grants a round unattendedAbertaworkflow
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
kristofdegrave/homeassistant-smart-charging#1505 ·
Mantenedores costumam responder em até 1 dia
-
New Submission: TropWATERAbertametadata submission
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
canonical/content-cache-operator#163 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
[submission]Abertasubmission
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 65/100
leanprover/lean-eval-submissions#1852 ·
Mantenedores costumam responder em até 1 dia