30 lines
739 B
Python
30 lines
739 B
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
import sys
|
|
from time import sleep
|
|
|
|
from serial import Serial # type: ignore
|
|
|
|
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
|
|
|
|
# for rate in [1200, 2400, 4800, 9600, 115200]:
|
|
for rate in [9600]:
|
|
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))
|