I'm trying to communicate with an instrument (Agilent 33220A arbitrary waveform generator) using GPIB and I use the GPIB-USB-HS interface plugged into a USB port on my computer.
The instrument is correctly listed when I use NIMAX explorer (there is also a Thorlabs PM100D connected by USB):
However, I cannot connect to it using PyVISA.
Here is the code:
import visa
rm=visa.ResourceManager()
rm.list_resources()
The output is:
('USB0::0x1313::0x8078::P0003982::INSTR', 'ASRL1::INSTR', 'ASRL3::INSTR', 'ASRL6::INSTR')
As you can see, the PM100D connected by USB is correctly listed, but not the Agilent connected on GPIB 10.
I tried to connect directly:
rm.open_resource('GPIB0::10::INSTR')
But I got an IO error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\users\nanotube\appdata\local\programs\python\python36\lib\site-packages\pyvisa\highlevel.py", line 1623, in open_resource
info = self.resource_info(resource_name, extended=True)
File "c:\users\nanotube\appdata\local\programs\python\python36\lib\site-packages\pyvisa\highlevel.py", line 1583, in resource_info
ret, err = self.visalib.parse_resource_extended(self.session, resource_name)
File "c:\users\nanotube\appdata\local\programs\python\python36\lib\site-packages\pyvisa\ctwrapper\functions.py", line 1381, in parse_resource_extended
alias_if_exists)
File "c:\users\nanotube\appdata\local\programs\python\python36\lib\site-packages\pyvisa\ctwrapper\highlevel.py", line 188, in _return_handler
raise errors.VisaIOError(ret_value)
pyvisa.errors.VisaIOError: VI_ERROR_RSRC_NFOUND (-1073807343): Insufficient location information or the requested device or resource is not present in the system.
I use Python 3.6.0 on Windows 7 Pro 64 bits OS. PyVisa version is 1.8.
I don't understand what I'm missing here. Does anyone have an idea ?
Many thanks !
I think this should work for you
rm.open_resource('USB0::0x1313::0x8078::P0003982::INSTR')
Related
I need help in python. I tried to put this code in python shell:
from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech", "127.0.0.1",9559)
tts.say("Hello, world!")
and I get this error:
Traceback (most recent call last):
File "C:/Users/USER/Desktop/say.py", line 2, in <module>
tts = ALProxy("ALTextToSpeech", "127.0.0.1",9559)
File "C:/Users/USER/Desktop\naoqi.py", line 227, in __init__
inaoqi.proxy.__init__(self, args[0], args[1], args[2])
File "C:\Python27\lib\site-packages\inaoqi.py", line 318, in __init__
this = _inaoqi.new_proxy(*args)
RuntimeError: ALBroker::createBroker
Cannot connect to tcp://127.0.0.1:9559
This order happen whether I use virtual robot or real, I use choregraphe 1.14.5 version and python version 2.7.13
The connection is almost never done to 127.0.0.1:9559:
If you're connecting to a real robot, you should replace 127.0.0.1 by it's IP address (or it's domain name, e.g. "nao.local", but may or may not work depending of your local network configuration; when it does work it's more convenient)
If you're connecting to Choregraphe's virtual robot, you should replace 9559 by the virtual robot's port, which you can find in Choregraphe's preferences, at the bottom of the "Virtual Robot" tab, as seen in this image.
I am trying to connect my raspberry pi to a Bluetooth OBD adapter. I have verified that the OBD device is working by connecting to it from the android phone using Torque lite app.
I am following this tutorial to connect the raspberry pi to the OBD adapter. I am able to pair with the OBD adapter and then trust it. Then I manually create the "/dev/rfcomm0" abstraction. As per the tutorial "screen /dev/rfcomm0" is supposed to print some output. But for me it just says "Screen is terminating" and it exits.
I tried running the "obd_reader.py" script, but it is throwing the following error:
python obd_reader.py
Ports:
['/dev/rfcomm0']
[obd.obd] ======================= python-OBD (v0.6.1) =======================
[obd.obd] Explicit port defined
[obd.elm327] Initializing ELM327: PORT=/dev/rfcomm0 BAUD=auto PROTOCOL=auto
Traceback (most recent call last):
File "obd_reader.py", line 11, in <module>
connection = obd.OBD(ports[0])
File "/usr/local/lib/python2.7/dist-packages/obd/obd.py", line 58, in __init__
self.__connect(portstr, baudrate, protocol) # initialize by connecting and loading sensors
File "/usr/local/lib/python2.7/dist-packages/obd/obd.py", line 85, in __connect
self.interface = ELM327(portstr, baudrate, protocol)
File "/usr/local/lib/python2.7/dist-packages/obd/elm327.py", line 137, in __init__
if not self.set_baudrate(baudrate):
File "/usr/local/lib/python2.7/dist-packages/obd/elm327.py", line 265, in set_baudrate
return self.auto_baudrate()
File "/usr/local/lib/python2.7/dist-packages/obd/elm327.py", line 293, in auto_baudrate
response = self.__port.read(1024)
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 460, in read
raise SerialException('device reports readiness to read but returned no data (device disconnected?)')
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected?)
I tried a suggestion provided here, but there was no change in output. This was the change suggested:
You need to add the SP profile editing this:
sudo nano /etc/systemd/system/dbus-org.bluez.service
Then add the compatibility flag -C for adding the SP to sdptool. Modify the lines from the file above to:
ExecStart=/usr/lib/bluetooth/bluetoothd -C
ExecStartPost=/usr/bin/sdptool add SP
I feel that I am creating or configuring the rfcomm device in the wrong way. But not sure how to fix this. Can someone please suggest a solution?
It seems that line 27 of the script you are running you are missing a dot in the query:
res = connection.query(obd.commands[command])
Tt should be like this as far as I know:
res= connection.query(obd.commands.[command])
So im trying to connect to a CoaP Resource using this python library https://github.com/chrysn/aiocoap . The library uses python 3.4 and i have 3.4 installed and set as the interpreter to use with this (Im on Windows 7 btw). Still im getting this error message, when executing the clientGET.py file. Same for the server file.
C:\Python34\python.exe C:/Learning/PyCoap/aiocoap/clientGET.py
Traceback (most recent call last):
File "C:/Learning/PyCoap/aiocoap/clientGET.py", line 34, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "C:\Python34\lib\asyncio\base_events.py", line 268, in run_until_complete
return future.result()
File "C:\Python34\lib\asyncio\futures.py", line 277, in result
raise self._exception
File "C:\Python34\lib\asyncio\tasks.py", line 236, in _step
result = next(coro)
File "C:/Learning/PyCoap/aiocoap/clientGET.py", line 20, in main
protocol = yield from Context.create_client_context()
File "C:\Learning\PyCoap\aiocoap\aiocoap\protocol.py", line 510, in create_client_context
transport, protocol = yield from loop.create_datagram_endpoint(protofact, family=socket.AF_INET6)
File "C:\Python34\lib\asyncio\base_events.py", line 675, in create_datagram_endpoint
waiter)
File "C:\Python34\lib\asyncio\selector_events.py", line 68, in _make_datagram_transport
address, waiter, extra)
File "C:\Python34\lib\asyncio\selector_events.py", line 911, in __init__
super().__init__(loop, sock, protocol, extra)
File "C:\Python34\lib\asyncio\selector_events.py", line 452, in __init__
self._extra['sockname'] = sock.getsockname()
OSError: [WinError 10022] Ein ungultiges Argument wurde angegeben
Process finished with exit code 1
I didn't explore this in a real Python, as I don't have a Windows machine with Python 3.4 handy, but it seems to me that this could be a bug in asyncio. Its UDP socket creation probably simply doesn't work on Windows. Do some experimenting on the lower level, looking at what aiocoap is doing, and try to prove me wrong.
It's supposed to work, documentation only mentions ProactorEventLoop as not supporting UDP.
The error condition is described in Socket.error: Invalid Argument supplied .
aiocoap.protocol.Context.create_client_context() seems to be doing the right thing according to asyncio documentation, but _SelectorTransport.__init__() will always call sock.getsockname() before any packets are sent, at which point the socket will not be bound to an address (according to the linked SO question) and getsockname() will fail on Windows.
You might want to retry with a current version of Python and aiocoap (current development version, after 0.4a1). Windows used not to be supported in aiocoap, and is still not supporting all of CoAP, but now uses a socket implementation that is aware of some limitations in the Windows socket API.
I'm trying to connect to a Netcool 7.1 Object Server using Python, but I'm running into issues. It seems to be a Sybase type database, but stripped down. I'm using the Sybase module and freetds, but I get the following error when I try to connect:
Traceback (most recent call last):
File "netcool.py", line 12, in <module>
db = Sybase.connect('foo','foo','foo','foo')
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 1194, in connect
datetime, bulkcopy, locale, inputmap, outputmap)
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 850, in __init__
self.connect()
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 898, in connect
status = conn.ct_options(CS_SET, CS_OPT_CHAINXACTS, not self.auto_commit)
File "/usr/lib64/python2.6/site-packages/Sybase.py", line 272, in _servermsg_cb
raise DatabaseError(msg)
Sybase.DatabaseError: Msg 17001, Level 10
No SRV_OPTION handler installed.
Has anyone successfully connected to a Netcool Object Server using Python? Is there any way I can edit the Sybase module to make it work? Worst case scenario, would it be possible to write something that communicates with the nco_sql client? I want the ability to read and write to the DB.
Any help or info would be greatly appreciated.
Eventually I figured this out on my own. If you use the SAP Sybase JDBC drivers (jconn4.jar) in conjunction with the JayDeBeApi module, you can successfully connect and read/write to the object server. This is the only Python solution I could find that works. If anyone else has an different method, feel free to share.
I have tried below lined of code on RHEL it works so great. On Linux I just have to acquire the Kerberos ticket.
mport ldap
import ldap.sasl
conn=ldap.initialize('ldap://auto.test-auto.com',trace_level=2)
conn.set_option(ldap.OPT_PROTOCOL_VERSION, ldap.VERSION3)
conn.set_option(ldap.OPT_REFERRALS,0)
sasl = ldap.sasl.gssapi()
conn.sasl_interactive_bind_s('', sasl)
Then I copied same thing in to a windows 2k3 server where ActivePython-2.7","python-ldap-2.4.10", "openssl-0.9.8o","setup-sasl-1.5.27" are installed.
Traceback (most recent call last):
File "C:\susanta\test-sasl.py", line 10, in <module>
conn.sasl_interactive_bind_s('', sasl)
File "C:\Python27\lib\site-packages\ldap\ldapobject.py", line 229, in sasl_interactive_bind_s
return self._ldap_call(self._l.sasl_interactive_bind_s,who,auth,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls),sasl_flags)
File "C:\Python27\lib\site-packages\ldap\ldapobject.py", line 99, in _ldap_call
result = func(*args,**kwargs)
LOCAL_ERROR: {'desc': 'Local error'}
Could some one help me out?
Are you using Cyrus SASL as backend? If so, it compiled against MIT or Heimdal. You don't have access to the TGT. Search for registry key: session key tgt.
But Cyrus SASL is not really usable on Windows if you use GSS-API unless you try Kerberos for Windows.