Start/stop device io

Hi Chris,

In some cases, with our labjack plugin, we only call start_device_io() on the first trial after experiment load. Occasionally when we do that, stopping the experiment and restarting will leave one of the hardware FIO inputs lines stuck high.

Any immediate thoughts on why that might happen? Is it generally ok to make those start/stop_device_io() calls only once per expt load and expect MWorks to deal with it appropriately on experiment stop/restart?

thanks and happy thanksgiving!
Mark

Hi Mark,

Is it generally ok to make those start/stop_device_io() calls only once per expt load and expect MWorks to deal with it appropriately on experiment stop/restart?

The behavior of start/stop_device_io is entirely up to the device itself. All the actions do is call a corresponding method (startDeviceIO or stopDeviceIO) on an instance of a subclass of IODevice. What happens in those methods isn’t under MWorks’ control.

Any immediate thoughts on why that might happen?

Not really. Are you explicitly calling stop_device_io at the end of the protocol, or are you letting MWorks call it implicitly when the experiment stops?

Chris

Not really. Are you explicitly calling stop_device_io at the end of the protocol, or are you letting MWorks call it implicitly when the experiment stops?

Does stop_device_io() always get called when the experiment is stopped?

Also, if there are actions that should be run every time an experiment is stopped for any reason (like the finally block of a try…finally statement in Python), where should they be put?

thanks,
Mark

Hi Mark,

Does stop_device_io() always get called when the experiment is stopped?

Yes, even if the device was already stopped or was never started. Your implementation of stopDeviceIO needs to handle those scenarios and only stop things that are actually running.

Also, if there are actions that should be run every time an experiment is stopped for any reason (like the finally block of a try…finally statement in Python), where should they be put?

At present, there isn’t any place to put them. Adding support for this has been on my to-do list for a long time but has yet to rise to the top.

Chris

OK, this is the info I needed - thank you. We’ll check it out.

Re: try…finally, that’s fine just keep us posted.
Mark