Answer the question
In order to leave comments, you need to log in
Pyserial how to send command to switch?
How to send a command to the switch using the PySerial library?
executing code
import os
import sys
import time
import serial
import serial.tools.list_ports
print('Ищем порт...')
ports = serial.tools.list_ports.comports(include_links=False)
for port in ports :
print('Нашли порт '+ port.device)
ser = serial.Serial(port.device)
if ser.isOpen():
ser.close()
ser = serial.Serial(port.device, 9600, timeout=1)
ser.flushInput()
ser.flushOutput()
print('Цепляемся к порту ' + ser.name)
ser.write("sh sw \r\n".encode('utf-8')) #Asks the Lock-in for x-value
while True:
response = ser.readline()
print(response)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question