LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble in reading data through USB communication with my Embedded device

Solved!
Go to solution

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

0 Kudos
Message 1 of 7
(2,267 Views)

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.


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
0 Kudos
Message 2 of 7
(2,234 Views)

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

 

 

0 Kudos
Message 3 of 7
(2,172 Views)

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.


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
0 Kudos
Message 4 of 7
(2,162 Views)

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??

 

0 Kudos
Message 5 of 7
(2,154 Views)
Solution
Accepted by topic author Dushy_11

@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.


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
Message 6 of 7
(2,147 Views)
Solution
Accepted by topic author Dushy_11

Thanks a lot. It workedSmiley Happy

0 Kudos
Message 7 of 7
(2,136 Views)