2023-04-07 19:13:32 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
from time import sleep
|
|
|
|
|
2023-12-08 12:45:05 +00:00
|
|
|
from serial import Serial # type: ignore
|
2023-04-07 19:13:32 +00:00
|
|
|
|
|
|
|
print(sys.path)
|
|
|
|
sys.path.insert(1, os.path.dirname(os.path.dirname(sys.argv[0])))
|
|
|
|
# from srnemqtt.constants import MAC
|
|
|
|
# from srnemqtt.lib.feasycom_ble import BTLEUart
|
|
|
|
from srnemqtt.protocol import construct_request, write # noqa: E402
|
|
|
|
|
2023-12-09 15:35:45 +00:00
|
|
|
# for rate in [1200, 2400, 4800, 9600, 115200]:
|
|
|
|
for rate in [9600]:
|
2023-04-07 19:13:32 +00:00
|
|
|
print(rate)
|
|
|
|
with Serial("/dev/ttyUSB0", baudrate=rate, timeout=2) as x:
|
|
|
|
sleep(2)
|
|
|
|
|
|
|
|
print(x)
|
|
|
|
|
|
|
|
write(x, construct_request(0x0E, words=3))
|
|
|
|
print(x.read(3))
|
|
|
|
print(x.read(6))
|
|
|
|
print(x.read(2))
|
|
|
|
|
|
|
|
# x.timeout = 2
|
|
|
|
|
|
|
|
# print(x.read())
|
|
|
|
# print(x.read(1))
|