DQMH Consortium Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

DQMH + tcp/ip streaming

Solved!
Go to solution

Hello,

 

First I would like to say that I am new to DQMH and really like it so far!
I was hoping to create a module that can handle a tcp/ip connection to my acquisition card (a red pitaya). The module should be able to open and close the connection, send commands to configure the acquisition, start the acquisition (streaming data), and stop the acquisition. I thought I could have a simple loop in my "Start Acquisition" event where I constantly poll the server for data (see picture attached), and then stop this loop when "Stop Acquisition" is called. Problem of course is that "Stop Acquisition" never gets executed because I am stuck in the streaming loop.
What would be the proper way to handle this? Is this the moment where I need to become familiar with the DQMH Generic Networking Module?

Thanks a lot for any help, I greatly appreciate it!

 

DQMH_question.png

0 Kudos
Message 1 of 5
(269 Views)
Solution
Accepted by topic author cecilec.

Hi cecilec,

 

Checking out the Generic Networking Module would certainly allow you to see how someone else would tackle this issue.

 

I have a networking module similar to what you're describing. So here are some of my tips for this:

1) If your communications is synchronous, ie. your application wants to send something or read something on demand, then you can do it all within the MHL, but this will mean your module is not acting dynamically - it's just sending/receiving messages when asked to do so. This is a good solution if the commands are only required on demand. All of this happens in the MHL:

   a) Start Acq Request established TCP connection

   b) Send message request sends a TCP msg on demand.

   c) Receive message request reads a TCP msg on demand.

       i) OR you might have a Send and Receive request that sends a TCP message and then waits for a specific TCP response.

   d) Stop Acq Request closes the connection.

 

2) If you want the module to have more flexibility  be more dynamic, take care of itself more, and need the module to run asynchronously, consider creating a helper loop to manage the TCP comms in your module.  My recommendation is that the TCP reference/handle is only used in the helper loop and not in the MHL.

   a) When you get a Start Acq request, use this to open and establish the TCP connection

   b) Then within your helper loop, periodically (say every 500ms) read the port for any new messages received and handle these (either right there in the helper loop, or pass it back to MHL as a private request for further processing)

   c) Have the helper loop handle Transmit msg requests, so that it performs this on demand.

   d) As soon as you get a TCP error (other than a timeout), you can deal with this, and attempt to automatically close/reconnect the port (just in case say you lose network momentarily, ie. cable is unplugged, but then plugged in again).

 

Hope this helps.

Christopher Farmer

Certified LabVIEW Architect and LabVIEW Champion
DQMH Trusted Advisor
Automated Production Test Specialty Premier Partner
https://wiredinsoftware.com.au

Message 2 of 5
(252 Views)

Hey cecilec,

 

happy to hear that DQMH works well for you!

 

Like Chris said, becoming acquainted with the GenNet modules will do no harm. However, they are designed to facilitate communication between two DQMH-based LabVIEW applications, so probably not the best fit for your use case.

 

With that being said, you might find it interesting to look at the TCP wrappers we have created for the GenNet modules.

 

1) GenNet abstraction and Variant-based protocol

2) GenNet String-based protocol




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )


0 Kudos
Message 3 of 5
(224 Views)

Thank you for your reply and the precision about the GenNet module. It sounds like this is not what I need for now!

0 Kudos
Message 4 of 5
(207 Views)

Thank you for pointing me towards the helper loop! I have moved my streaming code to the timeout event there and created some private requests to communicate with the MHL. I can now successfully start and stop the streaming!
Still a lot of details to iron out, but this looks like it will work!

 

Thanks again!

0 Kudos
Message 5 of 5
(204 Views)