Jump to content

VISA read timeout, all data received


Recommended Posts

Hi,

I'm connecting to a Rigol DZ1000 Oscilloscope via USB and using the :DISP:DATA? ON,0,PNG command to grab a screenshot. Reading out the data in blocks of 65535 bytes until there is no more (see attached vi).

This normally works fine but yesterday I was getting a timeout error. I fired up IO Trace and got this:

> 783.  viRead (USB0::0x1AB1::0x04CE::DS1ZA201305475::INSTR (0x00000001), "#9000045852‰PNG.......", 65536 (0x10000), 45864 (0xB328))
> Process ID: 0x000039C8         Thread ID: 0x00001760
> Start Time: 13:13:54.1169      Call Duration 00:00:10.4323
> Status: 0xBFFF0015 (VI_ERROR_TMO)

You can see that 45864 bytes were received, which is exactly what was specified by the binary data header (45852 data bytes + 11 header bytes + 1 termination char)

I dumped the reply string into a binary file and set the scope to run so it show something else on the screen. Sure enough the error went away. I also dumped a good result into a file. Then I tried to figure out what the problem may have been but I didn't get anywhere. Any ideas? Sure looks like a bug in VISA read or perhaps an incorrectly escaped reply from the scope?

It's very easy to "convert" the reply into the screenshot - just remove the leading 15 bytes (4 bytes from WriteBinayFile and 11 bytes from the scope header). And yes, both data files display just fine as PNG. I don't think PNG does internal checksum so byte errors would be hard to spot.

Any ideas what could have caused that timeout?

snip.png

Link to post
Share on other sites

I recommend you make a new VI to use the data block protocol.  Here's the code I use for this.  In short, you send your query command and read the # and the first number.  This tells you how many bytes are in the "size" section.  So you read that many bytes and convert that to a number.  This will now tell you how many bytes are in the actual data.  So read that many bytes and then 2 more to act as the termination character.  Now a key here is you need to turn off the termination character so that you don't have to keep trying to read more data due to a data value just happening to match the termination character.

1963548593_ReadDataBlock_BD.png.94a424cf553e98f59b2a4c4944da28e7.png

Link to post
Share on other sites
9 hours ago, ThomasGutzler said:

I see where you're coming form @crossrulz, but if the presence of a term char in the data was a problem, why am I getting exactly the right amount of bytes?

Because your logic is not robust. First you seem to use termination character but your binary data can contain termination character bytes too and then your loop aborts prematurely.

Your loop currently aborts when error == True OR erroCode != <bytes received is bytes requested>. Most likely your VISA timeout is a bit critical too?

Also note that crossrulz reads 2 bytes for the <CR><LF> termination character while your calculation only accounts for one. So if what you write is true, there still would be a <LF> character in the input queue that will show up at the next VISA Read that you perform.  

As to PNG containing checksum: Yes it does, multiple even! Each data chunk in the image data is compressed with the zlib deflate algorithme and this contains a CRC32 checksum!

Edited by Rolf Kalbermatter
Link to post
Share on other sites

Ok, I obviously got fooled by the abstraction of the VISA driver.

The reason why my initial code "works" is that I never enabled the Term Char. Without looking up the details of the communication protocol over USB I'm assuming that it contains some sort of "message end" that isn't a term char but is understood by VISA. Otherwise, I'd be getting timeout errors on the 65535 byte reads.

Nevertheless, I have changed my reads to the suggested method (but without term char enabled) and queried the scope using the old method until I got another timeout. And there is no timeout using the new method. This makes no sense to me knowing term char is disabled.

Finally, regarding the 1 byte vs. 2 bytes at the message end. All messages I'm getting end on "0A" but not "0D0A".

image.png.60817cb83e37bb44347fd7ec256acd0f.png

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By RMowatt
      I am experiencing numerous VISA Lock Errors (-1073807345) on resources I haven't explicitly locked.  This is happening on TCPIP connections to keysight N6700 power supplies and keysight N5242 PNA fairly regularly.
      I have simultaneous loops in the application communicating to the different instruments, using a sequencer of sorts to pipe commands one at a time to each of my various loops.
      Has anyone seen the locking error pop before while not actually using the Lock and Unlock VIs?  This issue has gotten worse lately and it has come time to find the root cause.  My only thoughts are that it may have something to do with having NI MAX and Keysight Connection Expert both installed and possibly trying to "ping" these devices.  Every once in a while me sending commands and these "pings" may clash and cause the locking error.
      Error reads as follows:
      "Specified type of lock cannot be obtained, or specified operation cannot be performed, because the resource is locked. VISA error code -1073807345 (0xBFFF000F)"
      We are using LabVIEW 2013
      Thanks in advance!
    • By Benoit
      Hey guys,
      Can you take a look at this?
      The only work around I found is to dynamically open the connection with an external VI to make it fail so the second time it works.
      If anyone has an instrument that communicate trough TCP-IP with VI, please try on your side with LabVIEW 2018 and visa 18.
      https://forums.ni.com/t5/LabVIEW/VISA-error-with-TCP-IP-BK-precision-2190E/m-p/3876316
      Thanks
    • By szewczak
      I wanted to cross post metux's discovery here asap, and have a separate discussion.
      Metux's original post:
      The recent Linux driver package introduces a CRITICAL security vulnerability:
       
      http://www.ni.com/download/ni-linux-device-drivers-2018/7664/en/
       
      It adds additional yum/zypper repos, but explicitly disabling package signing and using unencrypted HTTP transport. That way, it's pretty trivial to completely takeover the affected systems, by injecting malicious packages.
       
       
      DO NOT INSTALL THIS BROKEN SOFTWARE - IT IS DANGEROUS !
       
      CERT and BSI are already notified.
       
       
       
       
       
    • By Nishar Federer
      hi, 
      I need to make an application , which has to send a  hexa decimal data from labview to the protocol via RS232.I have sent a single data block(1Byte) and i was able to receive the acknowledgement properly. 
      But if i send a 9 bytes of Data through VISA via RS232, I am not getting any output at all , But if I send the same data block through different application, I am able to receive data . Can anyone suggest me way to resolve the issue or Better way to do this?? 
       
      I have attached my vI with this  . I am struggling at this point for so long.
       
       
       
      POC.vi
    • By PJM_labview
      Hi
      We have an application where we need to have a custom PCIe board transfer data to the PC using DMA.
      We are able to get this to work using NI-VISA Driver Wizard for PXI/PCI board.
      The recommended approach is to have VISA allocate memory on the host (PC) and have the PCIe board write to it (as seen below).

      While this approach works well, the memory allocated by VISA for this task is quite limited (~ around 1-2MB) and we would like to expand this to tens of MB.
      Note: The documentation (and help available on the web) regarding these advanced VISA function (for instance "VISA Move out 32" and "VISA Move In 32") is parse. If someone has some deep knowledge regarding theses, please feel free to share how we could allocate more memory.
      Since we are not able to allocate more memory using the VISA function at this time, we investigate doing the same operation using the LabVIEW Memory Manager Functions which allow us to allocate much larger memory block.
      Below is the resulting code.

      Unfortunately while we can validate that reading and writing to memory using this work well outside the context of DMA transfer, doing a DMA transfer do NOT work (although the board think it did and the computer is not crashing).
      We are wondering why this is not working and would welcome any feedback.
      Note: the DMA transfer implemented on the board requires contiguous memory for it to be successful. I believe that the LabVIEW Memory Manager Functions do allocate continuous memory, but correct me if I am wrong.
      To troubleshoot this, I did allocate memory using the LabVIEW memory manager function and try to read it back using VISA and I got a "wrong offset" error (Note: This test may not be significant)
      Another data point; while the documentation for DSNewPtr do not talk about DMA transfer, the one for DSNewAlignedHandle does. Experiment using LV memory manager Handles has not got us anywhere either.
      We would welcome any feedback regarding either approach and about the LabVIEW Memory Manager Functions capabilities in that use case.
      Thanks in advance.
      PJM
      Note: We are using LabVIEW 2014 if that matter at all.
       
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.