04-05-2017 02:40 PM
@billko wrote:
@lgc102 wrote:
Tried this method (event handler with Key Down?), got it to work more or less.
Can you somehow launch it async? I know, it's getting uglier and uglier...
Not really. I tried it as a subvi, and it doesn't pick up the keystrokes unless front panel is open and has focus. So, yes I could launch async, but front panel has to open, and that would be a mite confusing to the operators even if I make it hidden. Also starts crossing UI thread, so would slow down execution of stuff - not crucial, but might affect timing of other things.
Could make it happen, but that's a whole glob of new complexity to add...
Here's snippet of the (very messy) caliper keystroke listener, just for completeness sake.
04-06-2017 02:20 PM
Update, with a workable solution.
Digging around USB RAW stuff, found some beautiful nuggets here and here by Intaris, plus a nice example here and a NI-VISA USB tutorial here. Combining all this and digging into the HID Usage Tables of the USB Standard let met put together a driver subvi that takes non-focus control of a keyboard using NI-VISA, listens and extracts the string of interest, and parses the output. Seems to work pretty well on LV2015sp1.
A bit slow with the caliper: 1.5 to 2 sec per read, same speed that the caliper outputs to a string control using the normal Windows drivers, so this is a device limit not the code.
Of course as soon as I finished writing this, Starrett tech support told me that we had the wrong cable, they have one (not advertised on their web site) that allows direct USB interfacing without the keyboard nonsense, part number PT63388.
Anyway, here's the lvlib with the Starrett USB keyboard driver subvi, gratefully based on Intaris's examples in the nuggets. It can be adapted to other things at need. Find your device ID, use the NI-VISA wizard to override the existing drivers, and start tinkering.
04-07-2017 03:20 AM
@lgc102 wrote:
Update, with a workable solution.
Digging around USB RAW stuff, found some beautiful nuggets here and here by @Intaris, plus a nice example here and a NI-VISA USB tutorial here. Combining all this and digging into the HID Usage Tables of the USB Standard let met put together a driver subvi that takes non-focus control of a keyboard using NI-VISA, listens and extracts the string of interest, and parses the output. Seems to work pretty well on LV2015sp1.
A bit slow with the caliper: 1.5 to 2 sec per read, same speed that the caliper outputs to a string control using the normal Windows drivers, so this is a device limit not the code.
Of course as soon as I finished writing this, Starrett tech support told me that we had the wrong cable, they have one (not advertised on their web site) that allows direct USB interfacing without the keyboard nonsense, part number PT63388.
Anyway, here's the lvlib with the Starrett USB keyboard driver subvi, gratefully based on Intaris's examples in the nuggets. It can be adapted to other things at need. Find your device ID, use the NI-VISA wizard to override the existing drivers, and start tinkering.
Hey, don't forget to mark your post as the solution! 🙂