Products > Test Equipment

UNI-T UTG932/UTG962 200MSa/s Function Arbitrary Waveform Generator

<< < (89/96) > >>

aix:
tl;dr If you have an Ethernet-capable UNI-T AWG, I need your help - please see the bolded text towards the bottom. :)

Now that I have pyvisa working, I made a bit of progress on building an Ethernet to USBTMC bridge.

The UNI-T device manager can now discover the device over Ethernet:



Clicking buttons in the virtual UI also works as expected.

What doesn't work is getting screenshots from the device.  Here's where I'm at: the bridge receives Display:Data? from Device Manager, sends it to the device, successfully reads the bitmap and sends the bitmap back to Device Manager.  HOWEVER, Device Manager doesn't recognise it (fails quietly, doesn't display anything and doesn't write anything interesting to its log).

I think it's a data formatting issue.  Here's what I know so far:

In what I get from the device, there's an extra byte (0x01) before the bitmap.  See the hex dump at the bottom of this message.  Is this some header or a status byte I'm supposed to parse?  Anyway, if I drop this byte and display the image using feh, it looks fine.

The file size header field (0x0005fa00) is off: it only contains the size of the image data, whereas I think it's meant to contain the size of the entire file, i.e. including the header.  That said, I doubt it matters.

I think that UNI-T software wants to receive the bitmap in a different format than what I get from the device.  I tried various combinations of:

* removing the first byte; and
* adding a "#800012345"-style header as suggested on page 31 of https://events.uni-trend.com/hubfs/Instrument%20Product%20documentation/Waveform%20Generators/UTG4000A/UTG4000A%20Programming%20Manual%20V1.0.pdf with and without a terminating newline.
All to no avail.

I don't suppose one of you with an Ethernet-capable UNI-T AWG could do a bit of packet capture between Device Manager and device?  I'd be happy to help you operate Wireshark if that's not your thing.

$ xxd display_data_response.bin | head
00000000: 0142 4d00 fa05 0000 0000 0036 0000 0028  .BM........6...(
00000010: 0000 00e0 0100 0010 0100 0001 0018 0000  ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0002 0200 0000 0002 0200  ................
00000040: 3f3f 0c76 774c 9998 849f a184 9f9f 849f  ??.vwL..........
00000050: 9f84 9f9f 849f 9f84 9f9f 849f 9f84 9f9f  ................
00000060: 849f 9f84 9f9f 849f 9f84 9f9f 849f 9f84  ................
00000070: 9f9f 849f 9f84 9f9f 849f 9f84 9f9f 849f  ................
00000080: 9f84 9f9f 849f 9f84 9f9f 849f 9f84 9f9f  ................
00000090: 849f 9f84 9f9f 849f 9f84 9f9f 849f 9f84  ................
$ xxd display_data_response.bin | tail -n 4
0005fa00: 849d 9d84 9d9d 849d 9d84 9d9d 849d 9d84  ................
0005fa10: 9d9d 849d 9d84 9d9d 849d 9d84 9d9d 849f  ................
0005fa20: 9f84 9b9a 848b 8a80 6060 481d 1d04 0202  ........``H.....
0005fa30: 0002 0200 0202 00                        .......

renaatd:

--- Quote from: aix on October 07, 2024, 06:21:22 am ---tl;dr If you have an Ethernet-capable UNI-T AWG, I need your help - please see the bolded text towards the bottom. :)

--- End quote ---

My AWG is not ethernet-capable, so can't help with that. But just a small hint: the UNI-T device manager is written in C# or another .NET language, and is not obfuscated. It can be trivially decompiled with tools like ILSpy. That's how I got the details right for uploading waveforms.

aix:

--- Quote from: renaatd on October 07, 2024, 06:15:05 pm ---My AWG is not ethernet-capable, so can't help with that. But just a small hint: the UNI-T device manager is written in C# or another .NET language, and is not obfuscated. It can be trivially decompiled with tools like ILSpy. That's how I got the details right for uploading waveforms.

--- End quote ---

Yes, thanks for the suggestion.  I've looked the decompiled code and the decoding algorithm for :display:data? matches what my code produces.

I tried to step through both Device Manager and SCPI Control in a debugger to make sure I wasn't misreading the code.  In doing so I discovered that both of them segfault in the depths of VISA when trying to read the rather large response to :display:data? from a socket, i.e. even before reaching the decoding method.

I looked at buffer sizes and things like that but didn't see anything obvious.  I tried installing the latest version of NI VISA, but that didn't make a difference.

That's where I'm at.

A bit of a rabbit hole, this.

aix:
To make sure I wasn't fat-fingering the response to :display:data?, I made it return a small BMP image.  That works fine in Device Manager and SCPI Control.  If I increase the size of the bitmap beyond a certain size, I get an AccessViolationException from native code (viRead in visa32.dll).  The args getting passed to viRead look plausible.

The loaded visa32.dll is version 24.5.0.49310

edit: looking at instruction pointer in the exception object, it's inside the CopyUpLargeMov variant of memcpy, at the rep movsb instruction.  Unfortunately, I'm not set up for mixed-mode debugging and can't really tell whether it's the source or the destination buffer that's messed up, and how exactly.  I don't have a stack trace for the unmanaged part either, just the entry point (visa32.viRead) and the crash site (memcpy).  Hard to tell what goes on in between.

aix:
Progress!



I hypothesised that perhaps it was the RPC fragment size that was the problem, and it was!  Instead of sending the entire bitmap as a single large fragment (and relying on TCP to chop it up into segments), I now break the bitmap into 1024-byte fragments at the RPC level.  This seems to have fixed the VISA buffer overrun.

Unfortunately, UNI-T Control Panel still doesn't fully work.  It no longer crashes, but now shows a blank display.  I guess that's the next battle...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod