From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW Real-Time Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
QFang

"USB mount" programatic event on RT

Status: New

It would be nice if attaching a thumbdrive to a cRIO / RT usb port triggered a "mounted" event or interrupt in the RT OS. Currently the only way to discover if a thumbdrive has been connected is to periodically run a file/folder info VI and see if one is present. It would be nicer if we could register a dynamic event and wait for it using an event structure, or similarily register for an interrupt event would work as well.

 

In my case, the use-scenario is a field maintenance person going out and manually plugging in a thumb-drive about once every 4 weeks to get the stored log files off of the controller. (No, we cannot use remote access in this case due to customer network restrictions.) So, in my case, I can easily use the polling solution, but if there is one thing I don't like to do, its to write polling code of any sort. It seems so wasteful. Other possible use cases could be to detect the presence of a thumb-drive and check for patch/updates, copy over new configuration files, etc.

QFang
-------------
CLD LabVIEW 7.1 to 2016
2 Comments
ScotSalmon
Active Participant

Because of the way USB works (*), if we did provide this type of event, the implementation internally would still be a polling loop, it would just be one that we write instead of one that you write.  Depending on the reason for your preference to avoid polling code, this might not be an improvement and could even be worse, since it would be hard for us to know when you want to poll and when you don't care.

 

As a side note, in real-time software, polling usually gives better determinism than interrupts (because you can schedule your polling to happen at a convenient time for your RT application, as opposed to relying on an interrupt which may arrive in the middle of a time critical operation), at the cost of higher CPU usage (the "wasteful" aspect you noted).  Be sure to consider this tradeoff before dismissing the "wasteful" polling option.

 

(*) See for example http://www.embeddedsys.com/subpages/resources/images/documents/InterruptsAndUSB.pdf -- "with all transfers over USB the host must initiate the interrupt transfer."

QFang
Active Participant

Scot, I see your point. I was thinking that the enumeration event on the USB controller on the host could somehow be accessed as an event/interrupt. Is enumeration of new devices on the bus also handled by the OS/system polling then? If thats the case, this idea can just be killed as at that point I agree with you,  better I do my own polling when and if I need than have NI do polling in the background for me out of my control.

 

Thanks for the link and your comment! 

QFang
-------------
CLD LabVIEW 7.1 to 2016