ppannuto / python-saleae

Python library to control a Saleae Logic Analyzer
Apache License 2.0
125 stars 54 forks source link

Strange behaviour, nothing captured, CommandNAKedError. #31

Closed Ploppz closed 4 years ago

Ploppz commented 7 years ago

I have checked "Enable scripting socket server" in Logic. Using Arch Linux.

In python3 shell, when I first run s = saleae.Saleae(), Logic opens up, but the python line never returns (not even after closing Logic).

When I Ctrl-C in python shell, I get this error:

  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 136, in __init__
    self._s.connect((host, port))
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 139, in __init__
    Saleae.launch_logic()
  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 91, in launch_logic
    raise OSError("Failed to open Logic software. Is 'Logic' in your PATH?")
OSError: Failed to open Logic software. Is 'Logic' in your PATH?

Earlier, I changed /usr/bin/logic to /usr/bin/Logic. I'm using the saleae-logic package in Arch Linux (from AUR) - version 1.2.11.

Now, if I run sudo Logic in advance, s = saleae.Saleae() returns immediately.

After running s.capture_start_and_wait_until_finished(), then s.export_data2 always makes a file that has this content:

Time[s], Data[Hex]
0.000000000000000, 0

Here is a sequence of function calls that has some problematic output as well:

>>> s.set_capture_seconds(.5)
>>> s.capture_start_and_wait_until_finished()
>>> s.is_processing_complete()
False
>>> s.is_processing_complete()
False
>>> s.capture_stop()
False
>>> s.get_active_channels()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 517, in get_active_channels
    device = self.get_active_device()
  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 485, in get_active_device
    self.get_connected_devices()
  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 465, in get_connected_devices
    devices = self._cmd('GET_CONNECTED_DEVICES')
  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 200, in _cmd
    ret = self._recv(expect_nak=expect_nak)
  File "/usr/lib/python3.6/site-packages/saleae/saleae.py", line 191, in _recv
    raise self.CommandNAKedError
saleae.saleae.CommandNAKedError

It might be relevant that I have to run Logic with sudo in order for it to be able to find the logic analyser device. But since I already have to run sudo Logic in advance to make s = saleae.Saleae() return, I guess this is fine.

ppannuto commented 4 years ago

First -- apologies for having missed this and never replied :(. This is a pretty stale issue at this point, so I'm going to close it, but feel free to re-open if there's still something to be looked at here.

It's weird / problematic that Logic required sudo, that shouldn't be a thing (likely misconfigured udev rules allowing access to the USB peripheral?). I would look at fixing that first and then seeing if not running Logic as root doesn't fix other issues.