Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with bytes at port read in VISA

Solved!
Go to solution

Hi guys,

I'm trying to read data from device using usb-BT dongle. It creates the virtual port and read without problem. 

My problem is the device send packets of 428 bytes, inside of this block i have 400 bytes of data from byte 9 to 409. The first 3 bytes of each block is the same.

4D45 50 -- MEP, they are the first 3 bytes of each block of 428 bytes. 

 

Ok, if you check the vi, I config the visa and send Setting data to device, read the response and it sends the data to start to sendding data.

Well, I try to read each block of 428 and show in one graph.

The problem is sometimes bytes at ports are 428 and anothers shows 23, 2, 125,... is not continous 428 bytes each iteration and destroy the data graph.

IF I check the graph outside of main loop I see the graph correct. Outside of mainvi I collect whole data and separate in 428 blocks, extract the 400 bytes of data and parse the signed 16bits to integer and show in graphs.

 

So, I dont know the best way to get 428 bytes in each iteration.. I tried to directly read 428bytes but sometimes fail again, reading very low bytes... putting time to wait before to read bytes in each iteration... I need any way to get 428 values before to get the 400 data readings. Even I could probe each block start with the 4D4550 HEX bytes to pass and got the data... 

Maybe it would be better using queue? or using any while loop to wait until I got 428 bytes??. Any help will be apprecite.

 

Regards, Fred.

 

0 Kudos
Message 1 of 3
(4,196 Views)
Solution
Accepted by Fonsi

You are recieving binary data.  Therefore, turn OFF the the Termination Character.

 

What is happening is that you actually have 0x0D in your data.  The VISA Read sees that and then claims it is done reading the data.  By turning it off, then the VISA Read will read all 428 bytes or until a timeout happens.

 

Leave the constant instead of the Bytes At Port.


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 2 of 3
(4,192 Views)

Hi crossrulz,

 

Thank you, you are right!. I put the termination character for setting the device, but really it is no necesary since I am putting the termintation on string input.

Now works fine.

 

Thanks for help.

0 Kudos
Message 3 of 3
(4,172 Views)