Hi again-
I'm running into some problems working with the low-level DIO commands. The single-bit commands work fine, but the port commands are not.
Following are commands and results I am using:
Send: 54 F8 03 0B 4D 00 0D 00 40 00 00 00 - Which should set the E and F ports to DIO.
Rcv: 47 F8 03 0B 40 00 00 00 40 00 00 00 - No error.
Send: 3B F8 07 00 3B 00 00 1D FF FF 0F FF FF 0F - Which should enable and write all ports as outputs.
Rcv: 00 00 00 00 00 00 00 00 00 00 - The response does not look happy.
Send: 16 F8 01 00 1C 00 00 1C - Which should read the port directions.
Rcv: FB F8 03 00 00 00 00 00 00 00 00 00 - This indicates everything is an input.
Send: 88 F8 02 00 8D 00 00 0D 80 00 - Set FIO0 direction to Output.
Rcv: FA F8 02 00 00 00 00 00 00 00 - No error.
... (setting eact bit)
Send: 8F F8 02 00 94 00 00 0D 87 00 - Set FIO7 direction to Output
Rcv: FA F8 02 00 00 00 00 00 00 00 - No error.
Send: 16 F8 01 00 1C 00 00 1C - Which should read the port directions.
Rcv: FB F8 03 00 FF 00 00 00 00 FF 00 00 - Now it indicates that FIO is set to outputs.
So the ReadPortDirection (IOType=28) is working correctly, but I cannot get WritePortDirection (IOType=29) to work.
Send: 1B F8 07 00 1B 00 00 1B FF 00 00 FF 00 00 - This should enable writing FIO all to 1's.
Rcv: 00 00 00 00 00 00 00 00 00 00 - Again, not happy!
Send: 14 F8 01 00 1A 00 00 1A - Read DIO ports.
Rcv: 0B F8 03 00 0D 02 00 00 00 FF FF 0F - This indicates all ports are high, and there is a checksum error!
I've gone through this more than once, but cannot see what I have done wrong.
Any help would be greatly appreciated!
-Randy
The commands with the "not happy" responses of zeros:
Send: 3B F8 07 00 3B 00 00 1D FF FF 0F FF FF 0F
Send: 1B F8 07 00 1B 00 00 1B FF 00 00 FF 00 00
Have an error with the third byte, bolded above. In both commands they should be 4. 0.5 word for the echo byte, and 3.5 for the PortDirWrite/PortStateWrite, totaling 4.
The third byte is the number of data words after the Checksum16, where 1 word = 2 bytes.
Thank you! I switched to bytes instead of words.
Any idea why the ReadPorts command (IOType=26) is returning a checksum error?
Send: 14 F8 01 00 1A 00 00 1A - Read DIO ports.
Rcv: 0B F8 03 00 0D 02 00 00 00 FF FF 0F - This indicates all ports are high, and there is a checksum error!
Thanks again!
-Randy
The checksums in that response are correct.
The Checksum16 is calculated from bytes 6 and up, and the checksum8 is calculated from bytes 1 through 5. Details are here:
https://labjack.com/support/datasheets/u3/Low_Level_Function_Reference/G...