LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial read through VISA working fine in highlight mode but not in Normal mode

Hi,

 

   I am working an experiment to read values through USB cable. When i enable highlight mode and it runs fine and gives continuous values when i change the input but when i disable highlight mode it doesn't show any output. Can anyone tell me how to solve this problem. I am Using labview version 10 (academic license).  It is showing the error code -1073807339

 

Thanks

-Vikas

0 Kudos
Message 1 of 8
(3,275 Views)

Hi Vikas,

 

this error is the typical timeout error! (You should have read the error explanation before…)

 

Why is this?

Well you try to read 1000 bytes from the port. At 57600 baud this will take ~1000*10/57600s=174ms. But at InitSerialPort you have set a timeout value of just 10ms. Do you see the problem?

 

Solution: either read less than 57 bytes or increase the timeout value to reasonable values!

 

 

Best regards,
GerdW


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

Timeout value of 10msec is too small.

I too faced the similar thing when i set the timeout value of 100msec but after changing that everything works fine.

 

Message 3 of 8
(3,086 Views)

I never go below 1 second for a hardware timeout.  That should be plenty of time for an instrument to either respond to a command or just send out the next data point.  You have to allow enough time for the message to come in.


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,070 Views)

If you know the amount of data you will be receiving or transmitting I will calculate the timeout based on the port settings. Here is the code I use:

 

Calculate Serial Timeout.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 8
(3,030 Views)

Why are you converting all of those wires to SGL?

 

Should you be checking the parity setting as well and adding a bit for that if parity is set?

0 Kudos
Message 6 of 8
(3,023 Views)

@RavensFan wrote:

Why are you converting all of those wires to SGL?

 

Should you be checking the parity setting as well and adding a bit for that if parity is set?


Simply to avoid the data coericion. Since I am calculating the time required based on the data size and then set the timeout to 110% of the necessary time. I did it more to keep the code "pure" than any other reason. You are correct that the parity bit should probably be included.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 8
(3,014 Views)

If you want a quick calculation that handles 99% of the serial port settings I have ran into, you could just do this.


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