03-14-2016 03:49 PM
When I change the NI USB CAN port number from something like CAN0 to CAN3, the command to discover the set port:
Status = ncGetHardwareInfo(index, 1, NC_ATTR_HW_FORMFACTOR, 4, port_check);
does not see the change, port_check[0] = 0, but it should be 3, as that is what it was changed to in NI MAX. If I set it back to 0 the Get Hardware will read it correctly. If I tinker with it for a LONG time when set to CAN3, the Get Hardware call will EVENTUALLY read 3.
I don't have this problem with PCI CAN, that reads the change first time and every time I change it.
So, what is it with NI USB CAN that it isn't reading the change right away?
03-15-2016 06:04 PM
Does this happen with multiple NI USB CAN devices? If you haven't tried multiple and have another available you should give it a shot. It may be an issue with just a single device and not inherent to USB CAN.
03-16-2016 10:01 AM
It is a little goofy how this works. I think much of the issue was because I was using the CAN bus set to a specific port (CAN0) and then I want to allow my user to change the port number (like to CAN3), and the CAN port was open from previous communications or from something while chaning the port in NI Max.
This would be for NI PCI CAN, NI PXI CAN, or NI USB CAN devices.
If I don't close the connected CAN port, then there is a problem (part of what I am seeing). But, even when I do close the CAN port, sometimes there is an issue reading from the change in the CAN port number that was changed in NI MAX.
So, I added the Close function before trying to implement the user requested change. The other thing is informing the user they may need to reset the CAN (there is a CAN Reset button on the utility - it closes the opened CAN port, and reconfigures it with the latest user requested settings); and finally, if CAN communications still does not return, inform the user they may need to reset the utillity (close and reopen).
Often it will work correctly because I added the Close _ more than 50% works correctly
When it doesn't, if the user hits the CAN Reset button that usually corrects things
Once in a while I have to reset my utility (close and reopen) - only about 10% of the cases end up here
So, I'm going to show this implementation and see if it is sufficient for my users.