I constantly get a "could not open port 'COM#' Access denied. Although there is not another program currently using the potentiostat



  • Hi Will,
    I am using Spyder, installed through anaconda on Windows 10. I am currently running python version 3.7.3. I suppose I am using the Python API. The code I am running is the one made available through the iorodeo python library



  • @jonathankam

    Are you trying to run it from the Spyder ipython console? If so you may be creating multiple instances of the serial device object which would be why you are getting the access denied error. A few other users have hit this issue as well. The easiest way to check this is to run the python program in the standard fashion from the command line instead of from inside the ipython REPL. Do you still have this issue when running from the command line?



  • I am running a .py file where I create a device object using the potentiostat module and assign it to the appropriate port. The error is returned through the iPython console. It has happened as well from the CLI



  • @jonathankam

    OK. But just as a check. Close Spyder and all ipython consoles that may be running, etc. Close anything the might have an open connection to the device. Then open a command line and run the python script. Do you still get the access denied response?



  • Thanks! I get a different error now: 'Potentiostal' object has no attribute 'test running'



  • Additionally I get other error messages such as:
    File "test.py", line 2, in <module>
    pstat = Potentiostat('COM8')

    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\Lib\site-packages\potentiostat\potentiostat.py", line 163, in init
    self.hw_variant = self.get_hardware_variant()

    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\Lib\site-packages\potentiostat\potentiostat.py", line 173, in get_hardware_variant
    msg_dict = self.send_cmd(cmd_dict)

    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\Lib\site-packages\potentiostat\potentiostat.py", line 612, in send_cmd
    msg_dict = json.loads(msg_json.decode())



  • @jonathankam

    The first thing the software does is send the potentiostat command to get the hardware variant from the device. It looks like this command is failing for some reason. The "json.loads" in the error message makes me think that it is not receiving a proper response to this command from the device. This generally happens when either the teensy has not been programmed with the firmware or if the firmware on the teensy has been overwritten for some reason.

    Could you send me the complete set of error messages along with the commands you sent. This will help me diagnose this issue.



  • i get these errors:

    Traceback (most recent call last):
    File "iorodeo.py", line 9, in <module>
    dev = Potentiostat(port)
    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\Lib\site-packages\potentiostat\potentiostat.py", line 163, in init
    self.hw_variant = self.get_hardware_variant()
    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\Lib\site-packages\potentiostat\potentiostat.py", line 173, in get_hardware_variant
    msg_dict = self.send_cmd(cmd_dict)
    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\Lib\site-packages\potentiostat\potentiostat.py", line 612, in send_cmd
    msg_dict = json.loads(msg_json.decode())
    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\lib\json_init_.py", line 348, in loads
    return _default_decoder.decode(s)
    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    Error in atexit._run_exitfuncs:
    Traceback (most recent call last):
    File "C:\Users\JFK's Thinkpad\AppData\Local\Programs\Python\Python37\Lib\site-packages\potentiostat\potentiostat.py", line 649, in atexit_cleanup
    if self.isOpen() and self.test_running:
    AttributeError: 'Potentiostat' object has no attribute 'test_running'



  • @Will-Dickson using the following code:

    from serial import Serial
    from potentiostat import Potentiostat

    pstat = Potentiostat('COM8')

    dev = Potentiostat('COM8')
    dev.set_curr_range('100uA')
    dev.set_sample_period(10)

    name = 'cyclic'
    param = {
    'quietValue' : 0.0,
    'quietTime' : 1000,
    'amplitude' : 2.0,
    'offset' : 0.0,
    'period' : 1000,
    'numCycles' : 5,
    'shift' : 0.0
    }
    dev.set_param(name,param)
    t,volt,curr = dev.run_test(name,display ='pbar')


Log in to reply