Showing results for 
Search instead for 
Did you mean: 

serial communication missing bytes

Dear sushmith_ks friend,

                                    This is what I learnt from my experience. May this doesnt suite your environment. But this is what I suggest.



Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
0 Kudos
Message 41 of 62



     He said his tester will keep on sending data until he sends stop command. So that means if he is not sending any command his tester will be sending bytes continuesly. Am I clear??

Thanking you,
0 Kudos
Message 42 of 62

Hello Friends, Ranjeet and Sushmith,

The discussion seems to be deviating. I am already using the tester, that means I am communicating with it sending the right commands, which are with me in documented format. I know what data the tester is sending thats why i can make out that some bytes are missing.



In your earlier post, Ranjeet, you said that when there is zero bytes at port, then reading zero bytes might be causing the problem. What will happen if i use write to port with nothing in the string to write ???




***Another thing Friends, I am not "He".

0 Kudos
Message 43 of 62

Miss archie,

                          No from byte at port what I mean to say is your while loop is running continously without any delay then say from example it is checking the byte at port in 10 ms. Then if the data is there it will read and write to the string after 10 ms it will again read and this time no data to it will write 0 bytes to the string i.e. empty string. Hence you will see all the empty string.



As you say -- 'What will happen if i use write to port with nothing in the string to write ???'


Why you are wasting resources as these are important resources and you are wasting CPU time, eventhough it will work but it will never be an optimzed code. Why cant you follow the simple rule as write someting then read something within timeout time otherwise communication error.


Follow this then you will use minimum CPU resources and VI will work faster.


Hope this is clear.





Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
Message 44 of 62

The reading loop with bytes at port and read n bytes should get all data... and a short delay between the reads doesn't hurt (9600 means is coarsly 1 character per ms) but prevent the PC running 100%

I would try without any handshake AND

Old equipment sometimes can't handle a lot of input (internal  interrupt issues) , I had success by writing the commands byte by byte with 5ms delay inbetween.




Greetings from Germany

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'

0 Kudos
Message 45 of 62

Apologize me if the proposed method was wrong, I shared the knowledge which i`m aware.Smiley Wink




0 Kudos
Message 46 of 62

This is a wild guess based on what I'm hearing from each person and the discussion, which is a little opaque, but what you probably want is a structure similar to the one I've attached. Just open the VISA session, and use the Booleans to decide which functions you are undertaking: just writing, just reading, both. It is not perfect, it is a 5 minute creation to illustrate a point based on a not clearly described requirement (English as a second language can make it difficult if things get confused/ambiguous - and I am talking about me).


Hopefully that will help a little and simplify the situation, as generally, the simpler something is, the easier it can be.

0 Kudos
Message 47 of 62

I'm looking at the picture from post #14, and a couple of ideas come to mind:

  1) Probe "Bytes at Port", or wire it out to an indicator. This will allow you to see how many Bytes are being read each time.

  2) You are using "Wait Until Next ms Multiple" instead of "Wait (ms)". Multiple might only wait 1 tick, while Wait (ms) will always wait that many milliseconds. (Not a big deal, just be aware.)

  3) If "Read String" gets larger each loop iteration, and there are a few functions processing it each time. If "Read String" gets large enough, the loop may start slowing down. One way to defeat this is to send the string to another loop for processing:


0 Kudos
Message 48 of 62

Dear KathrynB,


What is the use of these two case structure, See in the serial communication, if you are writing some command in the serial port then you are expecting some bytes hence asking user to read the data from serial port is not correct method(Here boolean).. One more thing what is the guarantee that when user will press read from tester then data is available at serial port.


And one more thing there is no guarantee that byte at port will read the wanting number of bytes but it will read only number of byte available at serial port at that time but there may be chances that say if the response is 10 bytes and tester has sent only 8 bytes and remaining 2 bytes at next time then this method will go wrong. Hence what I prefer is use VISA read with number of byte to be read as 10, then read operation will terminate when either timeout occurred or if 10 bytes are read.


I modified your code.


Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
0 Kudos
Message 49 of 62

Thanks a lot all of you for your suggestions.

I have tried different ways of communicating with the tester in the past week and have come up with some weird observations.
The code works fine on one PC, the one i used to develop the code, but if i change the PC, i start missing bytes.

The PC i used to develop the code is 32 bit, celeron and the other PC is dual core with EM64T.Can this have any effect??

One more thing, in the PC where i am missing bytes, if i connect a pendrive to it, then there is no data loss. Smiley Surprised

0 Kudos
Message 50 of 62