PI-PhysikInstrumente / PIPython

Python Library for using PI controllers with GCS command language
28 stars 3 forks source link

Manage None as serialnumber, but self.flush() get stuck #18

Open vertighel opened 7 months ago

vertighel commented 7 months ago

Tested on C-863-11 controller, with firmware 11.0.1.3.0,

If no serial number is detected (maybe after a firmware update), then getdevinfo() function in the piusb.py module fails to regexp.

I suggest to change

    try:
        return re.sub('[^a-zA-Z0-9-_*. ]', '', usb.util.get_string(dev, stringid))
    except ValueError:
        PIError('probably you do not have permission to access USB descriptors')
        raise

with

    try:
        try:
            return re.sub('[^a-zA-Z0-9-_*. ]', '', usb.util.get_string(dev, stringid))
        except:
            return usb.util.get_string(dev, stringid)
    except ValueError:
        PIError('probably you do not have permission to access USB descriptors')
        raise

so it can take None as serialnumber.

However, the example:

from pipython.pidevice.gcscommands import GCSCommands                                                                                                                                                                                                   
from pipython.pidevice.gcsmessages import GCSMessages                                                                                                                                                                                                   
from pipython.pidevice.interfaces.piusb import PIUSB                                                                                                                                                                                                    
with PIUSB() as gateway:                                                                                                                                                                                                                                
    print(gateway.enumerate())                                                                                                                                                                                                                          
    gateway.connect(serialnumber=None, pid=0x1007)                                                                                                                                                                                                      
    messages = GCSMessages(gateway)                                                                                                                                                                                                                     
    pidevice = GCSCommands(messages)                                                                                                                                                                                                                    
    print(pidevice.qIDN())     

get stuck on the self.flush() method on connect.

The same controller works with the PISerial interface if the ftdi_sio kernel module is loaded.

DetlefMaurel commented 7 months ago

Thank you for the detailed description of the issue. We will look into this as soon as possible and will let you know when an update of PIPython is available.

PI: SW-12548