mirror of
https://github.com/PotentiaRobotics/engine-software.git
synced 2025-04-09 23:00:21 -04:00
remove debug prints + add flask raspi code
This commit is contained in:
parent
44a2a9ff45
commit
7fba995989
|
@ -1,11 +1,4 @@
|
|||
/*
|
||||
Program: Receive Strings From Raspberry Pi
|
||||
File: receive_string_from_raspberrypi.ino
|
||||
Description: Receive strings from a Raspberry Pi
|
||||
Author: Addison Sears-Collins
|
||||
Website: https://automaticaddison.com
|
||||
Date: July 5, 2020
|
||||
*/
|
||||
|
||||
int i=0;
|
||||
void setup(){
|
||||
|
||||
|
@ -23,12 +16,11 @@ void loop(){
|
|||
if(data=="Data"){
|
||||
Serial1.println("Data");
|
||||
//Serial.println("req data from slave");
|
||||
delay(10);
|
||||
delay(3);
|
||||
if(Serial1.available() > 0){
|
||||
Serial.println("AAAAgot data");
|
||||
//Serial.println("AAAAgot data");
|
||||
String data2 = Serial1.readStringUntil('\n');
|
||||
|
||||
Serial.print("Hi Raspberry Pi! You sent me: ");
|
||||
Serial.println(String(data2));}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ int i=0;
|
|||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial1.begin(9600);
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -13,10 +12,8 @@ void loop() {
|
|||
if(Serial1.available() > 0) {
|
||||
i+=1;
|
||||
String data = Serial1.readStringUntil('\n');
|
||||
Serial.print(data.charAt(0));
|
||||
|
||||
if(data.charAt(0)=='D'){ //this took forever to resolve, just do first char comparisions for now
|
||||
Serial.println("true");
|
||||
Serial1.print(myStr+"_");
|
||||
Serial1.println(myStr2+i);
|
||||
|
||||
|
|
|
@ -14,6 +14,6 @@ while (1):
|
|||
i+=1
|
||||
send_string = ("Data\n")
|
||||
ser.write(send_string.encode('utf-8'))
|
||||
time.sleep(0.02)
|
||||
time.sleep(0.01)
|
||||
receive_string = ser.readline().decode('utf-8').rstrip()
|
||||
print(receive_string)
|
13
RaspPi-flask-recieve/server.py
Normal file
13
RaspPi-flask-recieve/server.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
import socket
|
||||
host='0.0.0.0'
|
||||
port=2345
|
||||
s=socket.socket()
|
||||
s.bind((host,port))
|
||||
s.listen(2)
|
||||
while True:
|
||||
conn,addr=s.accept()
|
||||
print("Connected by",addr)
|
||||
data=conn.recv(1024)
|
||||
print("received data:",data)
|
||||
conn.send(data)
|
||||
conn.close()
|
Loading…
Reference in New Issue
Block a user