LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Corrupt Serial Read VI ?

Solved!
Go to solution

I have a Serial device that sends a single Byte like L or H or D depending on its current status, once every second. The baud rate is 9600 and other settings are defaut for teh Serial port. 

I have checked this to work very reliably with the standard example in LV2017 and no issues at all. 

 

I then created a LV APP which was far more eloborate as it had to handle the message byte and based on that do something. I was working on this VI for some time when finally i hit a road block. It said framing error. 

 

I started removing all functionality one by one and am left with the one as attached.  Even now this does not work ... can anyone try to see if it works on thier PC ? It simply does not connect or even if it connects, quits saying framing error when stopped.  

 

I did not want to convert it to a snippet fearing if it can further modify behaviour. So attaching the VI as is. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 8
(3,192 Views)

Hi Moga,

 

- which COM port is selected in your EXE when that VI is called? Is there any setting at all as your VI shows an empty "SerialPort" control…

- did you try to handle an error by closing the COM port and opening it again?

- did you log all error codes you received?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 8
(3,176 Views)

@GerdW wrote:

Hi Moga,

 

- which COM port is selected in your EXE when that VI is called? Is there any setting at all as your VI shows an empty "SerialPort" control…

- did you try to handle an error by closing the COM port and opening it again?

- did you log all error codes you received?


Yes when I refresh it picked up COM15 which is the correct one to which the external device is connected. 

Open - close - open - close - power down - power up - resstart PC . Everything was tried many times

Hmm .. no did not log any error code as it only told one of the two : Framing erorr. / Operation timed out before Read completed. 

 

With everything remaining as is, including me, the attached VI works every time.  

 

Actually this bug with the earlier VI has been eating so much time. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 8
(3,169 Views)

@MogaRaghu wrote:

I have a Serial device that sends a single Byte like L or H or D depending on its current status, once every second.


Just 1 byte?  That is the entire message?  No termination character in this message?  Are there other messages the device could be sending out?  Do the other messages use the termination character?

 

If your instrument is only sending the 1 byte at all times, then just read 1 byte at a time.

 

 


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 4 of 8
(3,159 Views)

@crossrulz wrote:

@MogaRaghu wrote:

I have a Serial device that sends a single Byte like L or H or D depending on its current status, once every second.


Just 1 byte?  That is the entire message?  No termination character in this message?  Are there other messages the device could be sending out?  Do the other messages use the termination character?

 

If your instrument is only sending the 1 byte at all times, then just read 1 byte at a time.

 

 


This is the problem of the brief queries on the fourm. If we make it eloborate then responses are far and few and too brief there is lack of clarity !! 

 

The problem is the LabVIEW app needs to handle lot more than I mentioned and in one instance needs to download a large file with varying byte length but not exceeding 90 bytes.

 

Yes the incoming data has a line feed in the end. 

 

The LV app does send a short query but we have not got upto that stage. My actual problem is simple - two almost similar VIs ( have posted both ) - one works and the other does not. 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 8
(3,149 Views)

I know it sounds childish and non technical. 

But out of sheer frustration i copied the VISA Config SerialPort.vi from the working VI to the VI that was not working. 

And that solved the problem.  So I am going ahead with the full App which is nearing completion. 

 

Just have one doubt - there are two different Drivers - one for VISA and another for SERIAL. I initially installed VISA and all my Serial devices worked except in this particulr instance. So when i searched for solutions on Web I came across the Serial driver and installed. But I found that it did not install any new Menu item. 

Anyway I am not too clear on this mess and right now its working and so will get going...

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 6 of 8
(3,137 Views)
Solution
Accepted by topic author MogaRaghu

Wild guess if this is your problem, but the timeout is really defined in milliseconds. So 10 sec should be 10000. You "working" vi has 10000 as the timeout. The one that is giving you problems has a value of 10

 

10sec.PNG

Message 7 of 8
(3,136 Views)

@jamiva wrote:

Wild guess if this is your problem, but the timeout is really defined in milliseconds. So 10 sec should be 10000. You "working" vi has 10000 as the timeout. The one that is giving you problems has a value of 10

 

10sec.PNG


No wild guess. It is the fact. 

I had a doubt ... but just looking at the description in the Help page, went forward ignoring it. The help balloon should actually read as ms and n NOT sec. All right a learning to study the help file in detail - atleast there hey have mentioned it as millisecond. 

 

Can you also help me with the other query ? If I install the VISA driver does it install SERIAL driver ? It must be so as thus far I have NEVER installed the Serial driver separately and yet the Serial VIs worked without issue. 

 

Thanks.

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 8 of 8
(3,110 Views)