Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PyDAQmx (WriteDigitalLines on __del__ causing mafunction)

Please see the issue here: https://github.com/clade/PyDAQmx/issues/60

0 Kudos
Message 1 of 6
(2,817 Views)

Out of curiosity have you tried our python API https://github.com/ni/nidaqmx-python? The one you linked is older and <insert-something-about-how-we-dont-officially-support-it-here>. 🙂

0 Kudos
Message 2 of 6
(2,778 Views)

Exact same issue with the nidaxmx lib.

 

This is crazy I can't just leave all the outputs high on a program exit... I'm controlling solenoids and stuff.

0 Kudos
Message 3 of 6
(2,738 Views)

Can you post your new code calling nidaqmx-python package? Are you using a Python context manager like in the examples: https://github.com/ni/nidaqmx-python/blob/master/nidaqmx_examples/di_sw_timed.py? In your old posting, the lifetime of the task object has already ended before __del__ is called. That is why Python is giving you an exception.

 


@machinehum wrote:

Exact same issue with the nidaxmx lib.

 

This is crazy I can't just leave all the outputs high on a program exit... I'm controlling solenoids and stuff.


Digital output will stay in the last output state unless a device reset was performed or a new value is output. Are you referring to the toggling to low in your __del__ method? At that point, the object has already been deleted; that is what the exception is saying. See this stackoverflow post on when __del__ is called: https://stackoverflow.com/questions/1481488/what-is-the-del-method-how-to-call-it/2452895.

0 Kudos
Message 4 of 6
(2,733 Views)

https://pastebin.com/GuVDyir0

 

Okay I assumed __del__ gets called before the GC, I guess this is not the case. I've done things like this before when writing to a file etc...

 

So what's the best way to stuff the context of a channel into an object so I can access the data with something as simple as thing.high(), setting the bit high?

 

https://pastebin.com/hMxUhYJJ

 

This exhibited the same error as well

 

0 Kudos
Message 5 of 6
(2,724 Views)
0 Kudos
Message 6 of 6
(2,721 Views)