colinoflynn / pico-python

PicoScope Python Interface
Other
97 stars 78 forks source link

Problems with 5442B #35

Closed MikeSandford closed 10 years ago

MikeSandford commented 10 years ago

I've got a 5442B that I'm trying to get going under linux. I've installed the drivers and picoscope and I can view waveforms which is great.

So now I'm trying to get to the automated data collection part which is where pico-python comes in. I got it installed as devel and then copied & pasted the discover_devices.py file and changed everything from ps6000 to ps5000a since I have a 5000 series scope.

sandford@MikeLinux ~/software $ python discover_devices.py 
Traceback (most recent call last):
  File "discover_devices.py", line 14, in <module>
    allSerialNumbers = ps.enumerateUnits()
  File "/home/sandford/software/pico-python/picoscope/picobase.py", line 707, in enumerateUnits
    return self._lowLevelEnumerateUnits()
AttributeError: 'PS5000a' object has no attribute '_lowLevelEnumerateUnits'
sandford@MikeLinux ~/software $ 

I am not really sure where to go from here. I am running Picoscope 6 Beta which I have installed from the Picoscope dpkg repo as described on their website: http://www.picotech.com/linux.html

Any help would be greatly appreciated!

colinoflynn commented 10 years ago

Oops – bit of a bug/change in the 5000 series I guess! Use one of the other examples as a demo instead, as it will work with the 5000 series.

I’d suggest the AWG demo instead. It works with both devices (5000/6000), and demos how to sample data & display it. You can just delete/ignore the AWG part if you don't care about that!

Edit: Reply-by-email apparently must be used with caution. Cleaned up my response...

MikeSandford commented 10 years ago

Okay so I've been able to get my hands back on the unit (we started using it for other stuff right away) and I've tried the AWG demo.

sandford@MikeLinux ~/workspace/pico-python/examples $ python awgdemo.py 
Attempting to open Picoscope 6000...
Traceback (most recent call last):
  File "awgdemo.py", line 32, in <module>
    ps = ps6000.PS6000()
  File "/home/sandford/workspace/pico-python/picoscope/ps6000.py", line 148, in __init__
    super(PS6000, self).__init__(serialNumber, connect)
  File "/home/sandford/workspace/pico-python/picoscope/picobase.py", line 134, in __init__
    self.open(serialNumber)
  File "/home/sandford/workspace/pico-python/picoscope/picobase.py", line 712, in open
    self._lowLevelOpenUnit(serialNumber)
  File "/home/sandford/workspace/pico-python/picoscope/ps6000.py", line 158, in _lowLevelOpenUnit
    self.checkResult(m)
  File "/home/sandford/workspace/pico-python/picoscope/picobase.py", line 753, in checkResult
    raise IOError('Error calling %s: %s (%s)' % (inspect.stack()[1][3], ecName, ecDesc))
IOError: Error calling _lowLevelOpenUnit: PICO_NOT_FOUND (No PicoScope XXXX could be found.)
sandford@MikeLinux ~/workspace/pico-python/examples $ 

So then like before I changed the references from ps6000 to ps5000a and re-ran it and got this:

sandford@MikeLinux ~/workspace/pico-python/examples $ python awgdemo.py 
Attempting to open Picoscope 6000...
Segmentation fault
sandford@MikeLinux ~/workspace/pico-python/examples $ python awgdemo.py 

Then I started poking around in the ps5000a file and I saw all kinds of references to the ps5000a including the library "ps5000a" which seems to be the .NET/mono library. So I copied & pasted the whole file to ps5000b.py and replaced all the references from ps5000a to ps5000b. Then I changed the awgdemo.py file to import the ps5000b and ran it and got this:

sandford@MikeLinux ~/workspace/pico-python/examples $ python awgdemo.py 
Attempting to open Picoscope 6000...
Traceback (most recent call last):
  File "awgdemo.py", line 32, in <module>
    ps = ps5000b.PS5000b()
  File "/home/sandford/workspace/pico-python/picoscope/ps5000b.py", line 138, in __init__
    self.lib = cdll.LoadLibrary("lib" + self.LIBNAME + ".so")
  File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libps5000b.so: cannot open shared object file: No such file or directory
Exception AttributeError: "'PS5000b' object has no attribute 'handle'" in <bound method PS5000b.__del__ of <picoscope.ps5000b.PS5000b object at 0x1b0a650>> ignored
sandford@MikeLinux ~/workspace/pico-python/examples $ 

I started to go looking for the ps5000b library but I didn't know where on the filesystem to start. So I googled "picoscope linux" to try and find the packages again and hit this page: http://www.picotech.com/linux.html

I saw this snippet:

"h) PicoScope 5242A/B, 5243A/B, 5244A/B, 5442A/B, 5443A/B, 5444A/B devices
sudo [updater] install libps5000a"

Okay so the ps5000a library is the way to go. I can handle that.

So I go back to that file and try it again and see this (I have commented out printing the docstring):

sandford@MikeLinux ~/workspace/pico-python/examples $ python awgdemo.py 
Attempting to open Picoscope 6000...
Segmentation fault
sandford@MikeLinux ~/workspace/pico-python/examples $

Alright I say, perhaps the problem is that I don't have permissions. So I sudo:

sandford@MikeLinux ~/workspace/pico-python/examples $ sudo python awgdemo.py 
Attempting to open Picoscope 6000...
Found the following picoscope:
DriverVersion                 : PS5000A Linux Driver, 1.1.0.106
USBVersion                    : 2.0
HardwareVersion               : 1
VarianInfo                    : 5442B
BatchAndSerial                : CS239/015
CalDate                       : 09Sep13
KernelVersion                 : 0.0
DigitalHardwareVersion        : 1
AnalogueHardwareVersion       : 1
PicoFirmwareVersion1          : 1.3.3.0
PicoFirmwareVersion2          : 1.0.19.0
Sampling interval = 728.000000 ns
Taking  samples = 4121
Maximum samples = 8388576
Chosen channel range = 2
Waiting for awg to settle.
Done waiting for trigger
sandford@MikeLinux ~/workspace/pico-python/examples $ 

Now everything works. I don't think I had restarted my computer since I installed the device (since I run linux) and so even though I got added to the pico group the changes hadn't taken effect yet.

Sorry to open a ticket basically because of my ignorance.

MikeSandford commented 10 years ago

I also found that on my machine for the awgdemo.py program I had to change:

plt.show()

to

plt.show(block=True)

in order to keep the plot showing until I closed it rather than returning immediately. http://stackoverflow.com/questions/9280171/matplotlib-python-show-returns-immediately

hmaarrfk commented 10 years ago

Hi Mike,

I skimmed through your bug report. Could you please format the long post with "code" snippets to make it more readable (and possibly remove the printed __doc__ since it isn't very useful).

That said, the program should not have Seg faulted.....

I wasn't aware of the ps5000b library. If you feel like it, you can fork and suggest a merge with your addition. Is the ps5000b the new library?

Mark

MikeSandford commented 10 years ago

Hi Mark,

I tried making a 5000b wrapper for a 5000b library, but there is no 5000b library. I found that out by reading this page (http://www.picotech.com/linux.html) and seeing that they say the 5000a is for the higher-end 5000 series scopes. I thought there might be a different library since there was a library called 5000a but I was very wrong.

Sorry about the code block problem. I'm more used to stack overflow so I forget.

The tl;dr is that I had a permissions problem but I didn't figure that out until I tried a bunch of other stuff first.

hmaarrfk commented 10 years ago

ah ok. I guess I must have not read the part where the ps5000b library doesn't in fact exist.