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

cancel
Showing results for 
Search instead for 
Did you mean: 

Paralel loops and serial communication

Solved!
Go to solution

Hello,

 

In my current LabView Project I'm using the "Queued Message Handler" design patern. The Labview program has to fetch data from multiple devices connected to serial ports. For the devices where I'm mostly convernd of their status this way works as expected and good. The data in the answer is transmitted to the rest of my program using notifications.

 

However I also have a testrack to where I need to send multiple commands (from different loops) and (in most cases) need the answers from the testrack in the loop that transmitted the original question.

 

So now my question is: How can I check the answer in the transmitting loop while the other queue's are "unaffected" (it's ok for me if they see the answer as long as the original transmitting loop still get's the data). (Hoping) to make it more clear I also attached a picture of wat I would like to have)

 

I hope you can help me.

0 Kudos
Message 1 of 29
(3,233 Views)

Can you attach your VI ?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 2 of 29
(3,222 Views)

Well my project is already getting quite big and I prefer not to post it yet.

 

But since I also havn't written this part of my program yet it's also gona be a bit tricky to post.

0 Kudos
Message 3 of 29
(3,219 Views)

How you are implementing serial parser ?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 29
(3,208 Views)
Solution
Accepted by topic author TimBotsM

For each (serial, async,...) device write a queue controlled state MC that handle the device.

The control queue handle init,setup,fetch data, get statusXY, ...,free_device  and the outputs are named queues for the (standard) data stream and the additional (status) information.

The command queue data cluster not only contains the command plus parameters but also the name of the output queue for this command.

Like that the device state MC control each data request (and can for example cancel or shift a selfcal request during a measurement...)

(a good practice would be that the data is only send to existing, named queues 😉 )

 

 

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 5 of 29
(3,202 Views)

@Ranjeet_Singh At the moment I'm not 100% sure of my serial parser. My last attempt (using functional globals and queue's) looked something like the example attached. Although if you have better suggestions I'm open to it.

 

@Henrik_Volkers I missed your post in my reply. But can you explain your post a little more. Although I'm learning LabView quite fast I'm still fresh in the waters that are called LabView (and I yould like to prevent my "final" code to look something like this http://zone.ni.com/devzone/cda/pub/p/id/1735 (figure 1))

0 Kudos
Message 6 of 29
(3,195 Views)

What is the response size from each transmitter ?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 7 of 29
(3,179 Views)

I guess you mean by this a short description om my protocol so here it is:

Byte              
0 1 2 3 4 5 6 7
Start DSTAddr Command/response ProbeData DataHI DataLO Checksum End
0x02 (STX) 0x00-0x06 cardNo   0x0.. - 0x3.. = ProbeNo 0x00-0xFF 0x00-0xFF LRC (bytes 1-5) 0x03(ETX)
  0xFF broadcast (To all cards)   0x..0 - 0x..3 = ChannelNo        
  broadcast only allowed from master   0xFF if not used        
  In case of broadcast no answer            
               

 

So in basic it's a byte-orriented protocol that is 8 bytes long.

0 Kudos
Message 8 of 29
(3,176 Views)

I dont know your application but I did something. Try to modify this if this is OK.

I hope this is what you are looking for.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
Message 9 of 29
(3,166 Views)

@Ranjeet_Singh I modified your file a bit so you can see the result.

 

My testsystem returns 8 bytes to every 8 byte command. However my problem is not the serial parser but more how I can distribute the commands transmitted by each loop back to the respective loops.

 

I'm guessing the answer is somewhere in the post from Henrik_Volkers but I'm having problems understanding his post. (not the English part, but the labview part)

 

However while keep thinking over his post I'm wondering if it would be a "good design" to send with the command (to the serial parser) also a reference to the queue used in the transmitted loop.

Download All
0 Kudos
Message 10 of 29
(3,161 Views)