Showing results for 
Search instead for 
Did you mean: 

Serial port termination character status?

Are you using the Bytes at Port property to read only when there are bytes available?  Also, what do you have the buffer size set to in the VISA Read?  I believe these two things are the main pieces to the solution from above.

0 Kudos
Message 11 of 19

Hi rory,


Thank you for your reply. Please find attached my labview code. I can give you more details about my application. I want to be able to get number of character as a string. I give commands such as, Measure Voltage (MV?) and so on. The number of bytes being sent as a reply should be 5 character. For example: 0500 and cariage return. I can read the first character, for example 0500. But then I cant read the first character, for example 500. And it repeat all over again. So, I read : 0500 and then I sent MV? I read 500, and then I sent MV? I read 0500, 500, 0500, 500...


Please...Help me.

0 Kudos
Message 12 of 19

It looks like you are just using the Basic Serial Write-Read example.  But why does your VISA write function have the characters "1B" on it?  The normal VISA write has the characters "abc" showing there on the icon.


I also don't understand what you can and can't do.  You say "I can read the first charactyer, for example 0500."  Isn't that actually 4 characters?  "But then I can't read the first character, for example 500"?  Well that's 3 characters, and is the opposite of what you just said.


How does your instrument work if you were using hyperterminal instead?  If you send "MV?" what comes back?

0 Kudos
Message 13 of 19


My visa write function have the characters "1B" on it, because it's a sub vi. Please find attached my sub vi.


When I'm using hyperterminal, and then I send "MV", it will reply "0500". Second time I send "MV", it will reply "0500", Third time I send "MV" it will reply "0500".

But when I'm using labview, First time I send "MV", it will reply "0500". Second time I send "MV" it will reply "500", Third time I send "MV" it will reply "0500", 4th time I send "MV" it will reply "500" and so on. 4 characters alternating with 3 characters.


Any idea? What went wrong?

Any help would be appreciated. Thank you.





0 Kudos
Message 14 of 19

Hi, Have you tried putting in a smaller delay? Is your received while loop switch always on or you turn it on whenever your expect a read?.

LabVIEW 8.2,8.6,2009...still learning 😛
0 Kudos
Message 15 of 19

Yes, I tried from 0 to 20000 ms for delay before read. and my received while loop switch always ON. 

thank you.

0 Kudos
Message 16 of 19

One thing I'd suggest is that you don't configure your serial port and close the serial port on every loop iteration.  Put the configure before the loop, put the close after the loop.  It might be the cause of your problem.  If data is coming in while the port is closed or being configured, you will miss it.  (Though I don't see why that should be the case here.)


Also, if you run NI-SPY before you run your program, you'll be able to log the interaction of LabVIEW with the serial port and it may give you a clue as to what is going on.

0 Kudos
Message 17 of 19

Ravens Fan makes some great points. Try putting the configure serial port and close serial port sections of the code outside the while loop (on their respective left and right sides).  I also don't see why this would make too much difference, but it is something quick and easy to try (and is also a very good programming practice Smiley Wink) .  In addition, try adding a small ms wait to your while loop to ensure your CPU isn't being crunched too hard and possibly degrading your LabVIEW or serial performance.  I also don't see how this could make too much difference concerning the particular problem, but it's another good programming tip that's quick and easy.


A good NI-SPY tutorial can be found here:

After you do the SPY Capture, you'll be able to see all the activity on the serial port from NI's standpoint.  Perhaps there is something there that you'll be able to spot causing a problem.

0 Kudos
Message 18 of 19

Hi all,

It works 🙂 I put VISA configure serial port vi and VISA close vi outside the while loop and It gave desired result. Thank you very much for all your help.

0 Kudos
Message 19 of 19