File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323# from paho.mqtt.client import Client as MqttClient
2424# from paho.mqtt.client import CallbackAPIVersion
2525import json
26-
27- import pi_serial
26+ from pi_serial import UART as uart
2827
2928DEFAULT_MODEL_PATH = Path ("./model.pt" )
3029DEFAULT_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
Original file line number Diff line number Diff line change 11import json
22from time import sleep
3- import pi_serial
3+ from pi_serial import UART as uart
44from typing import List , Tuple , Dict
55from data_classes import Item
66import 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 :
You can’t perform that action at this time.
0 commit comments