-1

I am trying to establish communication with electrical test equipment for remote control and data logging with a python script. I am unable to even get off the ground. It looks like I am unable to open the port? Any help is appreciated. I am on a Windows machine using VSCode terminal.

PS C:\Users\AaronVaughan> py -m serial.tools.list_ports
COM6
1 ports found
>>> import serial                          
>>> ser = serial.Serial(port="COM6")
...        
serial.serialutil.SerialException: could not open port 'COM6': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
accdias
  • 5,160
  • 3
  • 19
  • 31
  • It seems like you don't have a `COM6` serial port on your system. Try opening `COM1`, for example. – accdias Dec 09 '22 at 17:41
  • I tried COM1 and got the same error ``` PS C:\Users\AaronVaughan> py -m serial.tools.list_ports COM6 1 ports found ``` It seems to find the port here as COM6 right? – Aaron Vaughan Dec 09 '22 at 17:54
  • Yep. Perhaps the account you are using doesn't have sufficient privileges. Try testing with another account. – accdias Dec 09 '22 at 17:58
  • Ahh, when I unplug the device, COM6 is still there in the device manager. I likely need a driver from the manufacturer. I'll check and get back to you. Thanks for looking at this. – Aaron Vaughan Dec 09 '22 at 18:15
  • I hope it works. :-) – accdias Dec 09 '22 at 18:39
  • 1
    Yep. Okay so, the drivers for [many] electrical test equipment is handled by NI (National Instruments). After using their app to determine the device name, serial number, and version, I was able to get control remotely using pyvisa. – Aaron Vaughan Dec 09 '22 at 23:38

1 Answers1

0

After acquiring the address, serial number, and version of the instrument, I gained access using pyvisa and libusb1. The address, SN, and ver. were acquired after driver installation from National Instruments and the device manufacturers website.

Some skeleton code below...

import pyvisa

rm = pyvisa.ResourceManager()

PM1 = rm.open_resource("USB0::0x0A69::0x0879::63212AL00409::INSTR")
PM1.write_termination = '\n'
PM1.read_termination = '\n'
PM1.timeout = 1000
PM1.write('*CLS')
print(PM1.query('*IDN?'))
PM1.write('*RST')