-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Raspberry Pi 4 VL805 bulk transfer problem #458
Comments
You can try running using pyvisa-py master. Rigol instruments are known to implement the USBTMC protocol in a nor fully rigorous manner and the master can circumvent that. Let me know if you get it to work. |
Hi Matthieu,
Thank you for the quick response. I installed the master version of
pyvisa-py and things actually got worse. Still had the issue on the RPi4,
but RPi3 broke also.
Was I supposed to upgrade to the master version of pyvisa too?
I will just keep using my older raspberry pi 3 as pyvisa-py is working just
fine with it.
Thank you for this great software, it saves me a lot of time.
-Chark Stanford
…On Tue, Sep 3, 2019, 7:29 PM Matthieu Dartiailh ***@***.***> wrote:
You can try running using pyvisa-py master. Rigol instruments are known to
implement the USBTMC protocol in a nor fully rigorous manner and the master
can circumvent that. Let me know if you get it to work.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#458?email_source=notifications&email_token=AHQZG6BVBW62JJAKI7IBSNTQH4MOZA5CNFSM4ITMTEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD52EGEQ#issuecomment-527713042>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHQZG6B4QRSMRKJUBSYR7JDQH4MOZANCNFSM4ITMTEWQ>
.
|
Could you post the traceback you get on your raspberry 3 ? |
Hi Matthieu,
Here is the visa.log_to_screen() traceback for the successful case (RPi3):
2019-09-04 22:17:50,002 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
Scope information: RIGOL TECHNOLOGIES,DS1104Z,DS1ZA192107675,00.04.04.SP3
2019-09-04 22:17:53,022 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
Wrote screen capture to filename "rigol_2019-09-04_22-17-53.png"
2019-09-04 22:17:58,126 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - closing
2019-09-04 22:17:58,128 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - is closed
Here is my python script:
class rigol_ds1054z:
# Constructor
def __init__(self, debug=False):
resources = visa.ResourceManager('@py')
# insert your device here
# resources.list_resources() will show you the USB resource to put below
self.oscilloscope =
resources.open_resource('USB0::6833::1230::DS1ZA192107675::0::INSTR')
self.debug = debug
if (debug):
visa.log_to_screen()
def print_info(self):
self.oscilloscope.write('*IDN?')
fullreading = self.oscilloscope.read_raw()
readinglines = fullreading.splitlines()
print("Scope information: " + readinglines[0])
* time.sleep(2)*
def write_screen_capture(self, filename=''):
self.oscilloscope.write(':DISP:DATA? ON,OFF,PNG')
time.sleep(1)
raw_data = self.oscilloscope.read_raw()[11:] # strip off first 11 bytes
# save image file
if (filename == ''):
filename = "rigol_" + datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
+".png"
fid = open(filename, 'wb')
fid.write(raw_data)
fid.close()
print ("Wrote screen capture to filename " + '\"' + filename + '\"')
* time.sleep(5)*
from rigol_ds1054z import rigol_ds1054z
scope = rigol_ds1054z(debug=True)
scope.print_info()
scope.write_screen_capture()
…-Chark
On Wed, Sep 4, 2019 at 4:32 AM Matthieu Dartiailh ***@***.***> wrote:
Could you post the traceback you get on your raspberry 3 ?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#458?email_source=notifications&email_token=AHQZG6APFLHJFG2FADHHUJDQH6MDZA5CNFSM4ITMTEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53IMHQ#issuecomment-527861278>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHQZG6FU4Y6V5NB4ZD7BBC3QH6MDZANCNFSM4ITMTEWQ>
.
|
Hi Matthieu,
Here is the traceback for the unsuccessful RPi4 case (same script as the
RPi3).
2019-09-04 22:36:18,442 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
Scope information: RIGOL TECHNOLOGIES,DS1104Z,DS1ZA192107675,00.04.04.S
2019-09-04 22:36:20,459 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
Traceback (most recent call last):
File "test_print_screen.py", line 6, in <module>
scope.write_screen_capture()
File "/home/pi/python_code/rigol/rigol_ds1054z.py", line 122, in
write_screen_capture
raw_data_list = self.oscilloscope.query_binary_values(':DISP:DATA?
ON,OFF,PNG')
File
"/home/pi/.local/lib/python2.7/site-packages/pyvisa/resources/messagebased.py",
line 715, in query_binary_values
data_points, chunk_size)
File
"/home/pi/.local/lib/python2.7/site-packages/pyvisa/resources/messagebased.py",
line 493, in read_binary_values
block = self._read_raw(chunk_size)
File
"/home/pi/.local/lib/python2.7/site-packages/pyvisa/resources/messagebased.py",
line 400, in _read_raw
chunk, status = self.visalib.read(self.session, size)
File "/usr/lib/python2.7/dist-packages/pyvisa-py/highlevel.py", line 345,
in read
ret = self.sessions[session].read(count)
File "/usr/lib/python2.7/dist-packages/pyvisa-py/usb.py", line 111, in
read
usb.USBError)
File "/usr/lib/python2.7/dist-packages/pyvisa-py/sessions.py", line 477,
in _read
current = reader()
File "/usr/lib/python2.7/dist-packages/pyvisa-py/usb.py", line 105, in
<lambda>
return self._read(lambda: self.interface.read(count),
File "/usr/lib/python2.7/dist-packages/pyvisa-py/protocols/usbtmc.py",
line 338, in read
response = BulkInMessage.from_bytes(resp)
File "/usr/lib/python2.7/dist-packages/pyvisa-py/protocols/usbtmc.py",
line 108, in from_bytes
assert msgid == MsgID.dev_dep_msg_in
AssertionError
2019-09-04 22:36:21,313 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - closing
2019-09-04 22:36:21,316 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - is closed
…-Chark
On Wed, Sep 4, 2019 at 10:31 PM C Stanford ***@***.***> wrote:
Hi Matthieu,
Here is the visa.log_to_screen() traceback for the successful case (RPi3):
2019-09-04 22:17:50,002 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
Scope information: RIGOL TECHNOLOGIES,DS1104Z,DS1ZA192107675,00.04.04.SP3
2019-09-04 22:17:53,022 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
Wrote screen capture to filename "rigol_2019-09-04_22-17-53.png"
2019-09-04 22:17:58,126 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - closing
2019-09-04 22:17:58,128 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - is closed
Here is my python script:
class rigol_ds1054z:
# Constructor
def __init__(self, debug=False):
resources = ***@***.***')
# insert your device here
# resources.list_resources() will show you the USB resource to put below
self.oscilloscope =
resources.open_resource('USB0::6833::1230::DS1ZA192107675::0::INSTR')
self.debug = debug
if (debug):
visa.log_to_screen()
def print_info(self):
self.oscilloscope.write('*IDN?')
fullreading = self.oscilloscope.read_raw()
readinglines = fullreading.splitlines()
print("Scope information: " + readinglines[0])
* time.sleep(2)*
def write_screen_capture(self, filename=''):
self.oscilloscope.write(':DISP:DATA? ON,OFF,PNG')
time.sleep(1)
raw_data = self.oscilloscope.read_raw()[11:] # strip off first 11 bytes
# save image file
if (filename == ''):
filename = "rigol_" +
datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") +".png"
fid = open(filename, 'wb')
fid.write(raw_data)
fid.close()
print ("Wrote screen capture to filename " + '\"' + filename + '\"')
* time.sleep(5)*
from rigol_ds1054z import rigol_ds1054z
scope = rigol_ds1054z(debug=True)
scope.print_info()
scope.write_screen_capture()
-Chark
On Wed, Sep 4, 2019 at 4:32 AM Matthieu Dartiailh <
***@***.***> wrote:
> Could you post the traceback you get on your raspberry 3 ?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#458?email_source=notifications&email_token=AHQZG6APFLHJFG2FADHHUJDQH6MDZA5CNFSM4ITMTEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD53IMHQ#issuecomment-527861278>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AHQZG6FU4Y6V5NB4ZD7BBC3QH6MDZANCNFSM4ITMTEWQ>
> .
>
|
Could you also post the traceback you get on pyvisa-py master ? I would prefer to avoid breaking your code with the new release. |
Hi Matthieu,
Here is the traceback on my good RPi3 after upgrading pyvisa-py to
0.4.0.dev0.
2019-09-05 19:36:04,574 - pyvisa - ERROR - Unknown attribute 1073676310
(0x3fff0016 - VI_ATTR_SEND_END_EN)
Traceback (most recent call last):
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/sessions.py",
line 377, in get_attribute
return self._get_attribute(attribute)
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/usb.py", line
160, in _get_attribute
raise UnknownAttribute(attribute)
UnknownAttribute: Unknown attribute 1073676310 (0x3fff0016 -
VI_ATTR_SEND_END_EN)
2019-09-05 19:36:04,581 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
2019-09-05 19:36:04,583 - pyvisa - ERROR - Unknown attribute 1073676312
(0x3fff0018 - VI_ATTR_TERMCHAR)
Traceback (most recent call last):
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/sessions.py",
line 377, in get_attribute
return self._get_attribute(attribute)
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/usb.py", line
160, in _get_attribute
raise UnknownAttribute(attribute)
UnknownAttribute: Unknown attribute 1073676312 (0x3fff0018 -
VI_ATTR_TERMCHAR)
2019-09-05 19:36:04,584 - pyvisa - ERROR - Unknown attribute 1073676344
(0x3fff0038 - VI_ATTR_TERMCHAR_EN)
Traceback (most recent call last):
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/sessions.py",
line 377, in get_attribute
return self._get_attribute(attribute)
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/usb.py", line
160, in _get_attribute
raise UnknownAttribute(attribute)
UnknownAttribute: Unknown attribute 1073676344 (0x3fff0038 -
VI_ATTR_TERMCHAR_EN)
Scope information: RIGOL TECHNOLOGIES,DS1104Z,DS1ZA192107675,00.04.04.SP3
2019-09-05 19:36:06,608 - pyvisa - ERROR - Unknown attribute 1073676310
(0x3fff0016 - VI_ATTR_SEND_END_EN)
Traceback (most recent call last):
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/sessions.py",
line 377, in get_attribute
return self._get_attribute(attribute)
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/usb.py", line
160, in _get_attribute
raise UnknownAttribute(attribute)
UnknownAttribute: Unknown attribute 1073676310 (0x3fff0016 -
VI_ATTR_SEND_END_EN)
2019-09-05 19:36:07,611 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last
status <StatusCode.success_max_count_read: 1073676294>)
2019-09-05 19:36:07,613 - pyvisa - ERROR - Unknown attribute 1073676312
(0x3fff0018 - VI_ATTR_TERMCHAR)
Traceback (most recent call last):
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/sessions.py",
line 377, in get_attribute
return self._get_attribute(attribute)
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/usb.py", line
160, in _get_attribute
raise UnknownAttribute(attribute)
UnknownAttribute: Unknown attribute 1073676312 (0x3fff0018 -
VI_ATTR_TERMCHAR)
2019-09-05 19:36:07,614 - pyvisa - ERROR - Unknown attribute 1073676344
(0x3fff0038 - VI_ATTR_TERMCHAR_EN)
Traceback (most recent call last):
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/sessions.py",
line 377, in get_attribute
return self._get_attribute(attribute)
File "/home/pi/.local/lib/python2.7/site-packages/pyvisa-py/usb.py", line
160, in _get_attribute
raise UnknownAttribute(attribute)
UnknownAttribute: Unknown attribute 1073676344 (0x3fff0038 -
VI_ATTR_TERMCHAR_EN)
Wrote screen capture to filename "rigol_2019-09-05_19-36-07.png"
2019-09-05 19:36:12,710 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - closing
2019-09-05 19:36:12,713 - pyvisa - DEBUG -
USB0::6833::1230::DS1ZA192107675::0::INSTR - is closed
…-Chark
On Thu, Sep 5, 2019 at 11:44 AM Matthieu Dartiailh ***@***.***> wrote:
Could you also post the traceback you get on pyvisa-py master ? I would
prefer to avoid breaking your code with the new release.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#458?email_source=notifications&email_token=AHQZG6DELCNCMV33ARUTRNTQIFHSBA5CNFSM4ITMTEW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6AJN5I#issuecomment-528520949>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHQZG6AMLOJ3SW4MREBF56DQIFHSBANCNFSM4ITMTEWQ>
.
|
Using the master branch, does it help if you change chunk_size like so? inst.query_binary_values(':DISP:DATA? ON,OFF,PNG', chunk_size=2000*1024) If not, maybe play around with the chunk size value (try chunk_size > or = total data size). |
Can you try pyvisa/pyvisa-py#207 ? It should the attribute issue on the USB backend. |
Hi Matthieu, Specifying the chunk_size also did not help (Thx bjaraujo). 2019-09-11 21:00:10,494 - pyvisa - DEBUG - USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last status <StatusCode.success_max_count_read: 1073676294>) |
Thanks for testing. I still have no idea why the Raspberry 4 show the issue but we are doing something incorrect for quirky devices (ie which uses the wrong MsgId) in trying to convert the data to string. I pushed a temporary fix to pyvisa/pyvisa-py#207 but it would need some refinement (testing just for ; in any place looks dangerous to me). If you can test again it would be great. I will try to come with better fix in the meantime. |
Your latest change fixed the errors but the payload was only 104 bytes (I was expecting 30k bytes). It looks like valid data is being removed. Certainly it is an improvement. |
Please note that |
Hi Matthieu, I updated my script to be:
But I get this error: 2019-09-12 19:05:37,488 - pyvisa - DEBUG - USB0::6833::1230::DS1ZA192107675::0::INSTR - reading 20480 bytes (last status <StatusCode.success_max_count_read: 1073676294>) |
It would be interesting to print those first 104 bytes to see the header. |
You can have a look at https://pyvisa.readthedocs.io/en/latest/introduction/rvalues.html but it looks lile there is still something wrong in the usb backend. |
@bjaraujo You are right about the 104 bytes being the header (PNG header) here they are: Here is the first 1000 bytes of a successful transfer: ^G5..-^D?^\z?^^^?K^@M9^<F6>o^G ^A]!^Qa7_%ӷO<87>^? ^W0#̋5*{.z^Rg^^! <A0><D5>v:<99><9E>71^FF<C3>%<F0>^W+WW<F0><F8>^@<D9>"<B0>&<81><E4><EE><F3>K<DD><DB>^S<97><BD> <CD><C8>w({}^B<C1>k<8D><U+0082><97><FB><ED>۷<AF>_<BF>^^?"<8F>2"<E0>^@<91>-<FE>^P|J<99>~<E3>^O<FF>x!^@<91>T^Lf^D^D<D9>^?<FD><A9>^\c<89>PH<F9>^F<85>T<EC>^V<CE><FF><F3><97>N<9C>q+^V^@)Vݞ<8F>-<FF><8A>Uv^_;*<C1><F6><DC>^]>~<FC>8<EA><87><EF><D3>7O]<DA>}o<98>^Q<E6><C5>^Z<A9>o<BC><E2> <F1><AD><B0><D9>D<DB><<F9><D1>^B|<S x&MvjDZ<97> ^<90>S7^RX "<9D>L}e<8F>^Y="w<93>^FBZc<91>˭^K^Z$^@ew0(<9B>^?8<90>5^ Ҷ^Gؾ^U=^U |
If you know beforehand how many bytes to expect and do not need to convert them the more straightforward way is actually |
I installed wireshark and have the log files for the good and bad transfers. I can see the data differences from the start of the communication between the host and the oscilloscope. It looks like it could be in pyusb or libusb. Are there any pyusb connection options that could be tried to help this? |
I also thought this binary data had a header describing first the amount of bytes transferred but this data has no header, only the raw PNG data. In this case, I guess you have to be careful with the termination character as it will stop when it finds it. It may work or not depending on if it finds it or not. You could try setting inst.read_termination = None and then reading until it has no more bytes to read. |
Could you share those wireshark results ? |
I strip the first 11 bytes when I do a raw_read (as seen above in my "write_screen_capture" function)... the amount of bytes is probably listed in there. I have been relying on pyvisa's raw_read to skip the termination characters and just pass on the entire data that the scope sends. It has been working just fine using my Raspberry Pi 3. Here are the wireshark files. wireshark_print_screen_bad_rpi4.pcapng.gz I have noticed that there is a "SET ADDRESS Request" in the good logfile. I don't know if that is related to when pyusb does a detach_kernel_driver command. Thanks for your help. |
I am thinking that this is a pyvisa-py issue as I have no problems running on WIndows 10 using the NI backend. |
I am having a problem with query_binary_values() and read_raw() when downloading waveform or csv data from my Rigol DS1054Z. These commands run just fine on my RPi3, RPi2 and PC, but with the latest RPi4 (and the VL805) I am seeing errors.
Here is what I see from query_binary_values():
Here is what I see from read_raw():
If I wait one second after sending my write(':DISP:DATA? ON,OFF,PNG') command, I don't get any errors, but I only download 41bytes of data (when expecting 30KB).
Is this an issue with the VL805?
I suspect this is not a pyvisa issue, but a problem with bulk transfers with the VL805.
The text was updated successfully, but these errors were encountered: