bicarlsen / easy-biologic

Python library for communicating with Biologic devices.
GNU General Public License v3.0
18 stars 11 forks source link

KeyError: -7 #18

Open ulipoto opened 2 years ago

ulipoto commented 2 years ago

I used python -m easy_biologic.find_devices in the terminal to find my potentiostat and got "VMP3: USB0" as a result. Using that for bl = ebl.BiologicDevice('VMP3: USB0') does not work. The error received is: EcError: ERR_COMM_CONNECTIONFAILED (-201): Could not establish communication with instrument.

Using only "USB0" returns KeyError: -7. And apparently, error -7 does not exist in the error list.

The Biologic USB driver is installed and the EC-lab software works fine with USB connection. I'm using the Biologic VMP3B-10 potentiostat.

Do I maybe use the wrong keyword with 'USB0'?

Code:

import easy_biologic as ebl
import easy_biologic.base_programs as blp

bl = ebl.BiologicDevice('USB0')

Full error:

File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_errors.py", line 108, in __init__
    ( code, message ) = EcError.errors[ value ]

KeyError: -7

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "D:\Python\untitled0.py", line 12, in <module>
    bl = ebl.BiologicDevice('USB0')

  File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\device.py", line 61, in __init__
    self.populate_info()

  File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\device.py", line 209, in populate_info
    self.connect()

  File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\device.py", line 178, in connect
    ecl.init_channels(

  File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_lib.py", line 864, in init_channels
    validate( err )

  File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_lib.py", line 1615, in validate
    raise EcError( err )

  File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_errors.py", line 111, in __init__
    raise ValueError( f'Unknown error value {value}.' )

ValueError: Unknown error value -7.`
bicarlsen commented 2 years ago

It seems this error is coming from easy_biologic.lib.ec_lib#init_channels where BL_LoadFirmware is called.

From the User's manual (EC-Lab Development Package: Users Guide, Version 6.00 - April 2017) The error is (ERR_GEN_NOCHANNEL[S]ELECTED, no channel selected).

Back tracking a bit, it appears that the issue is coming from easy_biologic.device.BiologicDevice#connect where self.info.NumberOfChannels is being used to determine the channels to initialize. This info is coming from the call to easy_biologic.lib.ec_lib#connect to get information about the channels, My best guess is that this is where something is going wrong.

Unfortunately, I don't have access to a VMP3B-10 and can not recreate the error on my devices, so you may have to do some playing around. I suggest printing out BiologicDevice.info before the call to ec_lib#init_channels to verify the channels are correct, and if not, try to traceback from there where the issue is being caused.