You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there! When I tried to use the bio_logic module to control my potentiostat (SP-150e), it returned an error message saying TypeError. The script I used is from the test example of the package. And I am quite sure I have typed the IP address correctly as a string.
Could anyone help me with this issue? Thanks a lot!
Traceback (most recent call last): File "D:\Scripts\test.py", line 310, in <module> test_cv_technique() File "D:\Scripts\test.py", line 166, in test_cv_technique sp150.connect() File "D:\Anaconda\envs\test_env_EClab\lib\site-packages\PyExpLabSys\drivers\bio_logic.py", line 260, in connect address = create_string_buffer(self.address) File "D:\Anaconda\envs\test_env_EClab\lib\ctypes\__init__.py", line 66, in create_string_buffer raise TypeError(init) TypeError: 192.168.72.01
C:\Users\wan376\AppData\Local\Programs\Python\Python311\python.exe C:/Users/wan376/PycharmProjects/faster2/Potentiostat/test_potentiostat.py
Traceback (most recent call last):
File "C:\Users\wan376\PycharmProjects\faster2\Potentiostat\test_potentiostat.py", line 57, in <module>
run_ocv()
File "C:\Users\wan376\PycharmProjects\faster2\Potentiostat\test_potentiostat.py", line 12, in run_ocv
sp150.connect()
File "C:\Users\wan376\PycharmProjects\faster2\Potentiostat\bio_logic_driver.py", line 262, in connect
address = create_string_buffer(self.address)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\wan376\AppData\Local\Programs\Python\Python311\Lib\ctypes\__init__.py", line 66, in create_string_buffer
raise TypeError(init)
TypeError: 192.168.0.257
The code I ran was a copy paste of the example code from read the docs.
def run_ocv():
"""Test the OCV technique"""
ip_address = '192.168.0.257' # REPLACE THIS WITH A VALID IP
# ip_address = 'USB0'
# Instantiate the instrument and connect to it
sp150 = SP150(ip_address)
sp150.connect()
# Instantiate the technique. Make sure to give values for all the
# arguments where the default values does not fit your purpose. The
# default values can be viewed in the API documentation for the
# technique.
ocv = OCV(rest_time_T=0.2,
record_every_dE=10.0,
record_every_dT=0.01)
# Load the technique onto channel 0 of the potentiostat and start it
sp150.load_technique(0, ocv)
sp150.start_channel(0)
Sorry, for the slow answer time. This seems to be a signature that changed over time, maybe after the whole Python2/3 debacle. The create_string_buffer function now expects bytes not str. So, if that is the only place where the IP-address is used, you could make a workaround by converting your IP-address to bytes before sending it into the class. Something like:
Activity
KennethNielsen commentedon Aug 9, 2023
Hi @DangerLin
I missed this in the inbox before vacation. If this is still a problem, can you share the code you use to connect?
JustAnEmployee commentedon Aug 29, 2023
Hi @KennethNielsen I've got the same issue with this issue.
The code I ran was a copy paste of the example code from read the docs.
The point at which the code failed was
I'm running python 3.11.4 in a windows environment.
DangerLin commentedon Aug 29, 2023
Hi Kenneth, my code is attached below:
DangerLin commentedon Aug 29, 2023
Hi, sir, if you have a solution, could you please let me know? Thank you!
KennethNielsen commentedon Nov 2, 2023
Sorry, for the slow answer time. This seems to be a signature that changed over time, maybe after the whole Python2/3 debacle. The
create_string_bufferfunction now expectsbytesnotstr. So, if that is the only place where the IP-address is used, you could make a workaround by converting your IP-address to bytes before sending it into the class. Something like:if this works, I will make a fix around it.