09-01-2019 01:44 AM
Hi All
I am stuck with a problem and could not find out any solution to get out of it. Pls help me out to diagnose what could be the possible problem and how to get rid of it. My problem is as follows:-
I am trying to communicate my PC (Labview 2013 version) with my Embedded device through USB communication at 57600 BAUD RATE. Communication is happening and i am able to send command and embedded device is also sending me the reply data packet.
But the problem is when ever i send a command packet from PC (my command packet is of 7 bytes with 5th byte as my data byte, which i keep on increasing in a For loop based on my number of events), the device suppose to return me 17 Bytes against each event (with Start of Byte as 02 & End of Byte as 03).
While FOR Loop iterates for the first time asking for 1st 17 byte packet, i get only 5 bytes starting from Start of Frame byte of 02. But from 2nd iteration onward i receive complete 17 bytes but it starts from 6th byte of the Packet till end of frame byte of 03 then first 5 bytes of the packet starting with Start of Frame 02 and keeps on doing the same till last packet.
When i am using the same command with different tool (Docklight), data packet is receiving properly.
I am attaching the screenshot of the code which is used for this.
Pls suggest me the solution for this, so that i will receive the packet in same order without the loss of any single byte
Thanks in advance
Dushyant
Solved! Go to Solution.
09-01-2019 05:59 AM
DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (still not enough emphasis)
You expect 17 bytes back, so just tell the VISA Read to read 17 bytes. You also don't need all of those waits when you do this.
But where is your initialization code? It is also possible you have the Termination Character on. Since you are using a binary/hex/raw data format, you need to make sure that is turned off.
09-02-2019 06:21 AM
Thanks for your expert suggestion. I have straightaway removed BYTES AT PORT and asking VISA to read 17 bytes and also removed all the waits in between.
Attaching my Initialization code. Actually I am initializing the "VISA Configure Serial Port" in one window and then passing its "VISA resource name out" to different windows with different functionality.
Pls suggest have I initialized the VISA correctly or what I suppose to do to get the correct data without missing any byte
09-02-2019 06:29 AM
Yeah, you need to turn off the Termination Character. It is a Boolean input on the top of the VISA Configure Serial Port. As it is now (defaulting to TRUE), if your data just happens to have a byte value of 10 (0xA) in it, your read will stop prematurely. So wire a FALSE to that input to turn that feature off.
The Termination Character is extremely useful when dealing with ASCII messaging (you can read the data in a simple text editor) since any good ASCII protocol ends with a Carriage Return and/or a Line Feed. But, since you are dealing with binary/hex/raw data, you need to make sure that is off.
09-02-2019 07:05 AM
So now it is fine or I should insert this property node each time before VISA READ each time I want to read the data.
If this is fine then I am again getting the same data.
Also pls enlighten me that if in case my data packet consists of both hex data & ASCII data, then will it make difference??
09-02-2019 07:23 AM - edited 09-02-2019 07:24 AM
@Dushy_11 wrote:
So now it is fine or I should insert this property node each time before VISA READ each time I want to read the data.
There is the input on the VISA Configure Serial Port. Just wire a FALSE to that. And since everything else, except the Baud Rate, are the defaults, just done even have them. It is just more information (and diagram space) that you don't need.
Something else I just noticed: Set the mechanical action for your OK Button to be "Latch When Released". This will cause the button to reset when its terminal is read. In this case, it is read when the event case is handled. This will also eliminate the need (and capability) for writing to the local variable.
@Dushy_11 wrote:
Also pls enlighten me that if in case my data packet consists of both hex data & ASCII data, then will it make difference??
It all depends on your protocol. I cannot say more without knowing the details.
09-02-2019 08:29 AM
Thanks a lot. It worked