Hi, I wonder if the following is meant to work? Here, in Python 2.7.15, I set a digital I/O port high, then read the port.
def bitset(chan,bit): # called with channel and bit (1/0)
d.getFeedback(u6.BitDirWrite(chan,1)) # enable write on FIO channel 'chan'
d.getFeedback(u6.BitStateWrite(chan,bit)) # set FIO channel 'chan' to 'bit'
def bitget(chan): # Called with channel
d.getFeedback(u6.BitStateRead(chan) # Get state of specified port (1,0,tristate)
bitset(3,1) # Set FIO3 high
print bitget(3) # Print the returned value of bitget()
Is that a legitimate (though arguably silly) thing to do?
BitStateRead will not change the direction of the line ... it will remain an output ... so nothing wrong with what you are doing. If your prior commands did not throw an error then you know the line is set to the state you commanded, but the read is not totally meaningless. If you set the line to output-high, but something external is holding the line low (e.g. a jumper to GND) you will likely read low.