LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Loss in Serial Read during Multiple Ports read situation

Hi Everyone,

I'm working on a project where I'm capturing the Serial data from an external source (Aircraft LRU). I'm having data cluster to save port configurations to a file and using Multicolumn ListBox to save the data structure definition. I use these two criteria to configure my ports and sort the incoming data from the pre-defined data schema. I'm showing the frame read count, CRC check and failure % to the front end user during the data acquisition.

        The issue I'm facing is the Ports 1 & 2 and Ports 3 & 4 are receiving same data packets which means that they should have the same log file size at the end of the simulation . But, in my case they aren't having the same log file size (snippet attached - 'Datalogs1.jpg') and I'm quite not sure about how to fix this issue. I have used all the guidelines mentioned by the seniors in this forum in terms of configuring the ports and reading from the ports and all. But, I need to know why there's discrepancy in my datalog. The thing is I'm logging the raw data whatever I'm receiving from the ports and not doing any data manipulation on top of that. Please help me out in fixing this issue. My apologies for the lengthier code, since I'm new to LABVIEW the code might look messier. I have attached my project source code and snippet of my Serial data read, data structure file (Sim_Struct.txt) and data buffer process vi along with it. Please let me know if I'm missing any inputs required to guide me through the issue, Thanks in advance

 

Regards,

Madan Mohan  

0 Kudos
Message 1 of 17
(1,471 Views)

You've missed the guide line where it says "don't use bytes at port". (For example here: Bytes-at-Port-Property-Node-When-to-use-it-and-when-not.)

 

That one is evil.

 

The first iteration of the loop, the 1st device might not have bytes ready. The 2nd iteration had to wait for the 1st, so more bytes will be available. Etc.

 

Use end termination characters, if they are available. Or read a fixed number of bytes, if the message is fixed size. But do no use bytes at port.

 

I'd use the for loop's build in parallel execution. That will make the 4 devices read in parallel.

0 Kudos
Message 2 of 17
(1,448 Views)

Hi Madan,

 


@MadanMohan wrote:

I have used all the guidelines mentioned by the seniors in this forum in terms of configuring the ports and reading from the ports and all. But, I need to know why there's discrepancy in my datalog.


Then you need to debug: do you really read the same data for both group of COM ports?

Additionally you also clear any errors: how do you want to detect any problems with reading those COM ports?

 

On your VI(s):

Use plain ZIP to attach code. (Win)RAR is not used that much and needs to be paid for, while ZIP comes for free with each Windows/Linux installation!

IMHO you are using way too much local variables and references! Why do you use control references to forward values to all those configuration subVIs? Why not use simple wires connected to the control terminals? This would simplify all those subVIs as you don't need to use property nodes to read the "value" from controls…

You should clean up the code: use straight wires, especially for all those shift registers…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 17
(1,445 Views)

Hi Wiebe,

I just have a doubt that in my case, I have header '0x1' and footer '0x4' as packet identifiers which will also appear in my data payload. So, if I mention the footer as Termination character there are risks that the entire packet could break down during the read process. And another reason I'm using 'Bytes at Port' is there are chances that I will get more than one data packet in the port. So, I'm not particularly sure about how many bytes I would read at one instance. So, can you please shed some more light on fixing this issue and also please correct me if I'm going wrong anywhere

 

Regards,

Madan Mohan 

0 Kudos
Message 4 of 17
(1,442 Views)

Hi GerdW,

The data source (same data in different ports) is the client's requirements in case of data redundancy so mostly nothing can be done in that part. I'm clearing the errors after the Serial Read because I'm getting the error 'An overrun error occured during the transfer. A character was not read from the hardware before the next character arrived.' and I'm not sure how to handle this because I have seperated my data parsing loop to another case in the case structure which was mentioned in another thread for fixing the issue but still it didn't solve in my case. So, can you please give more insight on how to make approach on this. Meanwhile, I will work on cleaning my VIs and converting the references to controls in SubVIs 

0 Kudos
Message 5 of 17
(1,433 Views)

Hi Madan,

 


@MadanMohan wrote:

I'm clearing the errors after the Serial Read because I'm getting the error 'An overrun error occured during the transfer. A character was not read from the hardware before the next character arrived.'


Oh boy…

You get an error telling you you missed to read some data, but your only action is to clear that error message.

Now you wonder about missing data in your log files?

Really?

And you don't even mention this fact in the first place???

 


@MadanMohan wrote:

I'm not sure how to handle this because I have seperated my data parsing loop to another case in the case structure which was mentioned in another thread for fixing the issue but still it didn't solve in my case.


Read the COM ports more often!

Employ a producer-consumer scheme to separate COM port handling from data parsing into their own loops…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 17
(1,428 Views)

Hi GerdW,

This error seems to occur even when I mention fixed number for Bytes count to read from the port. And I don't clearly understand how to separate the read loop from other processes. My action sequences in the data capturing is as follows,

1. Get the port config cluster data from the enum ring input

2. Open the file prompt to mention the file name of data log

3. Read the raw data

4. Parse the raw data based on the available data structure as frames read and update it in GUI else add it to the shift register for the future case 

5. Log the raw data to the datalog, goes again to step 3 (continuous loop)

 

Since, the visa read is also a part of case structure according to the sequences mentioned above. I'm not clear on how to take it as separate process. Can you pls give more insight on this? My apologies if it looks like a very basic question

 

Regards,

Madan Mohan

0 Kudos
Message 7 of 17
(1,419 Views)

Hi Madan,

 


@MadanMohan wrote:

And I don't clearly understand how to separate the read loop from other processes. My action sequences in the data capturing is as follows,

1. Get the port config cluster data from the enum ring input

2. Open the file prompt to mention the file name of data log

3. Read the raw data

4. Parse the raw data based on the available data structure as frames read and update it in GUI else add it to the shift register for the future case 

5. Log the raw data to the datalog, goes again to step 3 (continuous loop)

Since, the visa read is also a part of case structure according to the sequences mentioned above. I'm not clear on how to take it as separate process.


Put steps 1&3 into it's own statemachine "SM1".

Put steps 2, 4 and 5 into their own statemachine "SM2".

Send raw data from SM1 to SM2 using a queue…

 

LabVIEW comes with a huge example library. There are also a lot of example projects. There are examples explaining how to implement statemachines, and there are examples for producer-consumer scheme. Please examine them…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 17
(1,414 Views)

Ok, we need to take a step back.  What is the format of the data frame?  It appears you are using a raw/binary scheme.  So for that reason, make sure the termination character is turned off.  Next, we need to exact frame definitions to properly read the data.

 

You might also want to watch this video: VIWeek 2020/Proper way to communicate over serial


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 17
(1,385 Views)

Hi CrossRulz,

The dataframe structure is:

     Header | Msg ID | No. of bytes | Data 1 ..... Data n | CRC_Low | CRC_High | Footer

 

I have turned off termination character in VISA Config VI. Thank you for the reference, I shall go through it and use it for my implementation methods

 

Regards,

Madan Mohan

0 Kudos
Message 10 of 17
(1,379 Views)