29 lines
703 B
Python
29 lines
703 B
Python
import serial
|
|
import time
|
|
|
|
# Configurações da porta serial
|
|
SERIAL_PORT = 'COM13' # Altere para a porta correta
|
|
BAUD_RATE = 9600 # Taxa de baud padrão do módulo
|
|
|
|
ser = serial.Serial(SERIAL_PORT, BAUD_RATE, timeout=1)
|
|
|
|
def read_parameters():
|
|
"""Lê os parâmetros atuais do módulo LoRa."""
|
|
command = bytes([0xc1, 0x00, 0x0b])
|
|
ser.write(command)
|
|
time.sleep(0.1)
|
|
response = ser.read_all()
|
|
print(f"Parâmetros atuais: {response.hex()}")
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
# Ler e exibir parâmetros atuais
|
|
read_parameters()
|
|
|
|
except Exception as e:
|
|
print(f"Ocorreu um erro: {e}")
|
|
|
|
finally:
|
|
# Fecha a conexão serial
|
|
ser.close()
|