Skip to content

Commit

Permalink
✨ Add device communication functs
Browse files Browse the repository at this point in the history
  • Loading branch information
NoaSecond committed May 31, 2024
1 parent a81b92a commit 5d8a8e6
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions scripts/deviceLibs/visaDevices.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,61 @@
import pyvisa


def list_connected_devices():
rm = pyvisa.ResourceManager()
devices = rm.list_resources()

lan_devices = []
for device in devices:
if 'TCPIP' in device:
lan_devices.append(device)

return lan_devices


def get_device_info(device):
rm = pyvisa.ResourceManager()
dev = rm.open_resource(device)
info = dev.query('*IDN?')
dev.close()

return info

def get_visa_list():

def get_visa_list():
device_list = []
for device in list_connected_devices():
device_info = get_device_info(device)
device_list.append(device_info + device)
return device_list
# Développé avec ❤️ par : www.noasecond.com.


def Connect(self, rsrcMgr, rsrcString, timeout, doIdQuery, doReset, doClear):
self.myInstr = rsrcMgr.open_resource(rsrcString)
if doIdQuery == 1:
print(self.QueryCmd("*IDN?"))
if doReset == 1:
self.SendCmd("reset()")
if doClear == 1:
self.myInstr.clear()

self.myInstr.timeout = timeout
return


def Disconnect(self):
self.myInstr.close()
return


def SendCmd(self, cmd):
if self.echoCmd == 1:
print(cmd)
self.myInstr.write(cmd)
return


def QueryCmd(self, cmd):
if self.echoCmd == 1:
print(cmd)
return self.myInstr.query(cmd)

0 comments on commit 5d8a8e6

Please sign in to comment.