LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

verification of my software code for best practice

I tried with giving fixed number of bytes (39) but in that case , it did not give me data after one loop, so i changed it to bytes at port.

 

 

So the correct way to read and write is to read and write in series with no wait. The one i have done in the attached sub VI. Right???

 

read write.png

 

0 Kudos
Message 31 of 34
(693 Views)

The Index array + build array is redundant, just wire the array to Array to cluster.

 

Well, it depends on your device. You mentioned it should send 39 chars. Does it not? Does it do it sometimes? Do messages use a termination character? Which character? 

If there's a termination character you should use that.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 32 of 34
(687 Views)

@Dushy_11 wrote:

 

So the correct way to read and write is to read and write in series with no wait. The one i have done in the attached sub VI. Right???


There are hundreds (thousands?) of discussions in thie Forum of reading from a VISA Port, and the problems caused by using "Bytes at Port".  In some cases this might be necessary, but it depends on the device sending information to LabVIEW that you are trying to read.

 

Many (most?) devices communicating by VISA send a text message, and terminate the message with a "Termination Character" (most frequently "Line Feed", \n, 0x0A).  In this case, you configure VISA to "Use a Termination Character", and you set your VISA Read to read "many more characters than you ever expect" (most common choices for Number of Characters are 1000 or 1024).

 

The idea is that VISA will read up to the Termination character and will return all the bytes (39, probably, in your case, assuming your device uses a Termination Character).  The VISA Read will wait until either it gets those characters or it times out (the default timeout is 10 seconds).  If your sending Device stops sending, and a Time-Out occurs, the VISA Read will exit with Error -1073807339, which you can detect, clear, and take appropriate actions.

 

Bob Schor

Message 33 of 34
(661 Views)

Sorry for late reply but I m really thankful to all the suggestions provided. I will surely work on my code and make it much more readable following all the best practices 

 

thanks a lot

Dushyant

0 Kudos
Message 34 of 34
(629 Views)