08-02-2017 11:14 AM - edited 08-02-2017 11:17 AM
Can I change the configuration of some ports from input to output and vice versa when a program is running? I'm using the MHDDK on Linux
11-14-2017 10:51 AM
You should be able to do this. You will need to stop the current action then do a port reset and reconfigure the direction. Here is a section of code from dioex2.cpp that could be useful to reference:
for (portIterator = ports.begin(); portIterator != ports.end() && status.isNotFatal(); ++portIterator) { (*portIterator)->reset(NULL, 0, status); } // // Program lines for input // for (portIterator = ports.begin(); portIterator != ports.end() && status.isNotFatal(); ++portIterator) { (*portIterator)->configureLines(lineMask, nNISTC3::kInput, status); } if (status.isFatal()) { printf("Error: Cannot program digital subsystem (%d).\n", status.statusCode); return; }
Instead of using the portIterator to iterate through all of the available ports, select the specific ports you want to change and do the reset and configureLines function calls on those. Also take a look at dioex1.cpp to see how to configure the ports for digital output. It is a similar process.