Skip to content
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

Linux Arch support to grap png over lan connection #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Kazhuu
Copy link

@Kazhuu Kazhuu commented Oct 17, 2021

Hello and thanks for this small script which also got me exited trying this out and to contribute to it.

Long story short. I have Linux Arch machine and the script didn't work for me out of the box. So here are some changes that I needed to do before it worked and some clean up.

  • Remove unnecessary time import
  • Change VIP_PID to be a list of supported identifiers. For some reason my machine returns identifier as 10-base number instead of hex.
  • Modify the search function to account for this new change to loop over the identifier list.
  • Add instructions to readme how to do the firmware upgrade. I needed to do this for this to work. I got timeout errors without it.

The tittle says that over lan connection because running this code doesn't work for me over usb. I get following error

/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa_py/protocols/usbtmc.py:115: UserWarning: Unexpected MsgID format. Consider updating the device's firmware. See https://github.com/pyvisa/pyvisa-py/issues/20
  warnings.warn(
Traceback (most recent call last):
  File "/home/kazhuu/programming/rigol-grab/rigol_grab.py", line 91, in <module>
    grabber.grab(filename=opts.filename, auto_view=opts.auto_view)
  File "/home/kazhuu/programming/rigol-grab/rigol_grab.py", line 22, in grab
    buf = self.rigol().query_binary_values(':DISP:DATA? ON,0,PNG', datatype='B')
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa/resources/messagebased.py", line 747, in query_binary_values
    return self.read_binary_values(
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa/resources/messagebased.py", line 602, in read_binary_values
    self.read_bytes(expected_length - len(block), chunk_size=chunk_size)
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa/resources/messagebased.py", line 371, in read_bytes
    chunk, status = self.visalib.read(self.session, size)
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa_py/highlevel.py", line 512, in read
    data, status_code = self.sessions[session].read(count)
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa_py/usb.py", line 149, in read
    return self._read(
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa_py/sessions.py", line 793, in _read
    current = reader()
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa_py/usb.py", line 133, in _usb_reader
    return self.interface.read(count)
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa_py/protocols/usbtmc.py", line 465, in read
    response = BulkInMessage.from_bytes(resp)
  File "/home/kazhuu/.local/share/virtualenvs/rigol-grab-ONTp5L5O/lib/python3.9/site-packages/pyvisa_py/protocols/usbtmc.py", line 113, in from_bytes
    msgid, btag, btaginverse = struct.unpack_from("BBBx", data)
struct.error: unpack_from requires a buffer of at least 4 bytes for unpacking 4 bytes at offset 0 (actual buffer size is 0)

I'm still digging in to this and trying to understand why. On linux for USB to work, you need to create udev rule to access usb device. Something along the lines

SUBSYSTEMS=="usb", ACTION=="add", ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="04ce", GROUP="usbtmc", MODE="0660"

These things could be added in the later PR if I figure out the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant