-
-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usbtmc assertion failure #20
Comments
I am glad that you find it useful. Regarding your error. I guess it might be because the length of the message and the fact that is being partitioned. Can you put a print just before the assert to see the values of |
As you say - it's in a loop pulling multiple buffers for the query response. run1: inst.query() call run2: inst.query() call run3: inst.query() call Hope this helps. Jason H. |
AFAIK, |
Here's a wireshark packet capture of the transaction. I'll see if I can get NI-VISA working. Thanks -jasonh |
Some other rigol/usbtmc references: |
So I have a quirk enable usbtmc.ko. The PID/VID matches so we should be running quirk enabled. I guess the next step is to build a custom usbtmc.ko and start playing with bigger buffer sizes. |
I am closing this as it seems to be outside the code of pyvisa-py. Please reopen if you think we can help from here. |
Linux, Python3 - talking to a Siglent SDG 805 Signal Generator. Identical issue. The SDG runs fine under Win10 with NI-VISA, that's why i am necromancing this issue. I can write to the device without problems. But reading from it, i run, as reported above, in an issue with the assertion. I can also confirm that this is linked to message partitioning by the device. The first message part is 64 Byte long. The second usually shorter, which appears to cause the assertion error. It seems As NI-VISA as a backend works, and as @classmethod
def from_bytes(cls, data):
msgid, btag, btaginverse = struct.unpack_from('BBBx', data)
# throw away trailing zeros
while data[-1] is 0:
data = data[:-1]
# if message in correct format, proceed as usual
try:
assert msgid == MsgID.dev_dep_msg_in
transfer_size, transfer_attributes = struct.unpack_from('<LBxxx', data, 4)
data = data[12:]
return cls(msgid, btag, btaginverse, transfer_size, transfer_attributes, data)
# otherwise, construct a correct response from the quirky device
except AssertionError as e:
return BulkInMessage.from_quirky(data)
@classmethod
def from_quirky(cls, data):
'constructs a correct response for quirky devices'
msgid, btag, btaginverse = struct.unpack_from('BBBx', data)
# check whether it contains a ';' and if throw away the first 12 bytes
if ';' in str(data):
transfer_size, transfer_attributes = struct.unpack_from('<LBxxx', data, 4)
data = data[12:]
else:
transfer_size = 0
transfer_attributes = 1
return cls(msgid, btag, btaginverse, transfer_size, transfer_attributes, data) I am uncertain, how this could conflict with other devices. I will likely be able to test it in February with a RIGOL DG 1062Z and a RIGOL 1052E |
This works on CentOS 7, Pyvisa, on a RIGOL DG812 @classmethod
def from_bytes(cls, data):
msgid, btag, btaginverse = struct.unpack_from('BBBx', data)
if msgid != MsgID.dev_dep_msg_in:
return BulkInMessage.from_quirky(data)
transfer_size, transfer_attributes = struct.unpack_from('<LBxxx', data,
4)
data = data[12:]
return cls(msgid, btag, btaginverse, transfer_size,
transfer_attributes, data)
@classmethod
def from_quirky(cls, data):
"""Constructs a correct response for quirky devices"""
msgid, btag, btaginverse = struct.unpack_from('BBBx', data)
# check whether it contains a ';' and if throw away the first 12 bytes
if ';' in str(data):
transfer_size, transfer_attributes = struct.unpack_from('<LBxxx', data, 4)
data = data[12:]
else:
transfer_size = 0
transfer_attributes = 1
print(cls)
return cls(msgid, btag, btaginverse, transfer_size,
transfer_attributes, data) |
Thanks for testing this on rigol @jondoesntgit. Based on this thread https://www.eevblog.com/forum/testgear/rigol-usbtmcvisa-interface-is-really-terrible/ it seems that updating the firmware on the instrument may fix the issue. |
I see, thank you! I also found that there were a bunch of extra b'\x00' bytes in the data strings, that I removed with a |
186: Added support for Rigol/"quirky" devices r=MatthieuDartiailh a=jondoesntgit This pulls in the changes from @agricolab in #20 Co-authored-by: Jonathan Wheeler <jonathan.m.wheeler@gmail.com> Co-authored-by: MatthieuDartiailh <marul@laposte.net>
Linux, Python3 - talking to a Rigol ds1102e scope.
Most operations complete ok.
Trying to get the channel data from the scope.
ie: rawdata = inst.query_binary_values(":WAV:DATA? CHAN1")[10:]
Which is on the order of 1024 n-bit values. (I think - not really sure)
usbtmc.py croaks.
Here are the setup details:
Thanks for PyVisa-py - I've gotten further with it than with librevisa.
Let me know if you need any more details.
Jason H.
The text was updated successfully, but these errors were encountered: