Merge pull request #6 from PotentiaRobotics/DevelopmentBranch

Put toA.py code into server.py
This commit is contained in:
Vrishak Vemuri 2023-01-14 15:04:17 -05:00 committed by GitHub
commit af8308cc53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,12 @@
import socket
#!/usr/bin/env python
import serial
import time
ser = serial.Serial('/dev/ttyACM0', 9600, timeout=2)
ser.flush()
host = '0.0.0.0'
port = 2345
s = socket.socket()
@ -8,6 +16,17 @@ while True:
conn, addr = s.accept()
print("Connected by", addr)
data = conn.recv(1024)
print("received data:", data)
conn.send(data)
# Get rid of garbage/incomplete data
# Infinite loop
ser.write(data)
time.sleep(0.01)
receive_string = ser.readline().decode('utf-8').rstrip()
print(receive_string)
conn.send(receive_string.encode())
conn.close()