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: 

VISA Serial

Solved!
Go to solution

Hi friends, i am writing a program to communicate to another computer via serial port, i am sending my bytes for every 1 sec, strange thing is happening which i dont understand that on every iteration of my while loop my byte index is shifting, please can anybody tell me whats going on with my code

 

Thanks

 

plz see attachement files

0 Kudos
Message 1 of 3
(1,061 Views)
Solution
Accepted by topic author Akbar7110

Well, your immediate issue is that you are sending 6 bytes, but only reading 5.

 

Other issues you have:

  • There is no real reason to flush your buffers immediately after opening the port.
  • Do not use Insert To Array to add to the end of an array.  Just use Build Array.
  • Instead of the formula express VIs, just use the actual primitives.  They are a lot more readable.
  • If using a non-decimal display for your constants, controls, and indicators, you really should have the radix visible (right-click, Visible Items->Radix).
  • You really should avoid a Sequence Structure if simple data flow can do the job.  This will also help eliminate your local variables.

 

If you want even better ideas for serial communication, you should really watch this: 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
Download All
Message 2 of 3
(1,030 Views)

Thank you very much

0 Kudos
Message 3 of 3
(1,011 Views)