Skip to content

Commit

Permalink
create littlebot mock
Browse files Browse the repository at this point in the history
  • Loading branch information
NestorDP committed Nov 28, 2024
1 parent 15352a8 commit 74e83ce
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions littlebot_base/scripts/littlebot_mock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 26 09:09:20 2018
@author: nestor
"""

import serial
import sys

serial_port = sys.argv[1]

ser = serial.Serial(serial_port, baudrate=115200) # open serial port

ser.write(str("hello\n").encode()) # write a string
ser.flush()
while True:
# Read one line from the serial port
if ser.in_waiting > 0:
data = ser.readline().decode('utf-8').rstrip()
print(f"Received: {data}")
if data == "exit":
break

ser.close()

0 comments on commit 74e83ce

Please sign in to comment.