05-27-2020 11:22 AM - edited 05-27-2020 12:18 PM
Hi,
I have a .net application that reads/writes ports in my ni6501 device.
I set some ports on port 0(door lock and powering on some devices), run my test and reset my ports.
For some reason, this is not working as expected, mainly resetting is not working and seems something may be reinitializing everything.
I am using 1 task for inputChannel and 1 task for OutputChannel in my device class.
Each task has input and ouputchannels defined.
I have GetState and SetState methods in my device class, where I set only the necessary bits, masking others and using WriteSingleSamplePort.
Each pin setting is a step and I initialize a device class instance for the operation.
Am I doing this correctly, any advise what may be going on? Can I get an example of a set bits, test, retest bits code?
Also, I have a read and a write in the same task on the same port, will this break something?
05-28-2020 12:36 AM
I figured the issue. In my application, I was trying to read from an output port and it was returning 255 all the time, no matter what the ports are set to.
I have port 0 as output port, port 1 as input port.
I want to set ports 0.0, 0.1 and 0.2 one after the other in that order. I use WriteSingleSamplePort() but I unable to use bit mask since I can't read the current state of port0(always returns 255). I don't want to assume the value they are set to.
My channelGrouping is OneChannelForAllLines. If I try to use OneChannelForEachLine, I get an exception that I cannot do this with DigitalChannels.
I am not sure how to go about writing the port using bit mask.
Any guidance appreciated.