Skip to content

Commit 5a00a2f

Browse files
committed
fixed pi_serial import
1 parent 20e7efa commit 5a00a2f

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

vision/detect.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
# from paho.mqtt.client import Client as MqttClient
2424
# from paho.mqtt.client import CallbackAPIVersion
2525
import json
26-
27-
import pi_serial
26+
from pi_serial import UART as uart
2827

2928
DEFAULT_MODEL_PATH = Path("./model.pt")
3029
DEFAULT_WEBCAM_PORT = 0
@@ -231,7 +230,7 @@ def main():
231230
item_change_counts[label] = 1
232231
if len(item_change_counts) > 0:
233232
data = json.dumps(item_change_counts) + '\n'
234-
pi_serial.UART.write(data.encode('utf-8'))
233+
uart.write(data.encode('utf-8'))
235234
# mqtt_client.publish(MQTT_VISION_DATA_TOPIC, payload=json.dumps(item_change_counts))
236235

237236

weight_predict/weight_predict.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
from time import sleep
3-
import pi_serial
3+
from pi_serial import UART as uart
44
from typing import List, Tuple, Dict
55
from data_classes import Item
66
import math
@@ -174,7 +174,7 @@ def main():
174174

175175
sleep(0.1)
176176

177-
line = esp_uart_port.readline().decode('utf-8', errors='ignore').strip()
177+
line = uart.readline().decode('utf-8', errors='ignore').strip()
178178

179179
if not line:
180180
continue
@@ -207,7 +207,7 @@ def main():
207207
json_str = json.dumps(json_data) + "\n"
208208

209209
# Send it to pi
210-
pi_serial.pi_uart_port.write(json_str.encode('utf-8'))
210+
uart.write(json_str.encode('utf-8'))
211211

212212
time_str = time.strftime("%H:%M:%S.") + f"{int((time.time() * 1000) % 1000):03d}"
213213
if item_change.quantity > 0:

0 commit comments

Comments
 (0)