07-18-2016 04:54 AM
Hello everyone,
I have a 2011 LabVIEW Real-Time application that I want to deploy on a PXIe-8100 for data acquisition. The application is a state machine whose functions I'd like to control via command line (over ethernet) on a remote computer. Essentially, I'm wanting to implement a two-way communication with the RT application using command line. Ideally I'd like to write a SCPI dictionary on the RT application such that I can type in a user-defined command on my computer's command line, have it be sent to the RT application, have the RT application parse the command, do whatever I had commanded it to do, and finally send me back a response.
From the research I've done so far, it seems like using Telnet might be the most promising for this (I tried to get this to work, but had minimal success, however). Other options might include using the "Open Application Reference.vi" along with a property node.
If anyone has any insight as to how this might be best approached, I'd very much appreciate your advice.
07-18-2016 02:16 PM - edited 07-18-2016 02:24 PM
If you really want the command line option, I would try the development in the following way (but I think it would be just easier to host a Remote Front Panel on the real-time target, and you can access it just using a simple browser + silverlight http://digital.ni.com/public.nsf/allkb/AB6C6841486E84EA862576C8005A0C26 😞
You could even set up a second argument as the IP address of your RT target, so this single command line application could send commands to different RTs if you have multiple on your local network.
Of course, you need to create some internal communication for getting the parsed command into your main RT while loop with that State Machine. I imagine you could use a Queued State Machine for your main while loop, and when a command comes, you insert the required state in front of the Queue in your TCP/IP server loop (priority msg).
Try to make your project, and if you see problems just attach your VIs here so people can help you.
Edit: if you need to get a response, then place a TCP Read function in your Client VI which will wait for the response sent from the Server...Then you can print the result back to command line...
Edit2: also check these:
http://www.notatamelion.com/2016/05/05/aint-misbehavin-thanks-to-external-calls/
07-18-2016 02:38 PM
Do you know how the Queued Message Handler works? There's a concept of a Message, a cluster having a "Msg" part (which can be a string "message" or an e-num "state") and a "Data" part, a variant in case (for a particular "message") some data needs to be passed.
I built both my Host and Remote programs around the Queued Message Handler. I then set up a pair of Network Streams that I used to send Messages from Host to Remote, and from Remote to Host.
Think of a "Message" as a "Command". Normally, the Host sends Commands to itself ("Initialize", "Create Data Files", "Start Recording"), and similarly the Remote also sends Commands to itself. Now suppose the Host wants to send a "Start Recording" command to the Remote. Instead of putting it in the Host's Message Queue, it sends it via a Network Stream to the Remote. The Remote has a "Listen for Messages" loop running in parallel with everything else it is doing, and if a Message from the Host shows up, it is placed on the Remote's Message Queue.
So the Host (perhaps in response to a Button Press) wants to tell the Remote to "Start Recording". It sends a "Start Recording" message (with optional parameters, if appropriate) to the Remote via the Network Stream. The Remote gets it, puts it on its own Message Queue, which causes it to start processing the "Start Recording" Message.
That's how the Host tells the Remote what to do. The Remote, in turn, can send results back to the Host by having a Remote-to-Host Network Stream for Messages. Suppose the Remote starts recording (because the Host told it to do so), and suppose it is supposed to take in 1000 points and then stop. When it stops, it can send a "Recording Done" Message to the Host through its Network Stream, and potentially even include (as the Data Parameter of the Message) the 1000 points. The Host has its own "Listen for Messages from Remote", and when one occurs, it packages it up and puts it on its Message Queue, where it is processed.
Network Streams are (now) a fairly robust communication mechanism in LabVIEW, and reasonably fast (besides the two Message Streams, I was also using a Network Stream to send 16-24 channels of 1KHz sampled data from the Remote to the Host, where they were then streamed to disk).
Bob Schor