aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x[-rw-r--r--].gitignore0
-rwxr-xr-xPI.py64
-rwxr-xr-x[-rw-r--r--]README.md0
-rwxr-xr-x[-rw-r--r--]System/__init__.py0
-rwxr-xr-x[-rw-r--r--]System/encoder.py0
-rwxr-xr-x[-rw-r--r--]System/homework8.ipynb0
-rwxr-xr-x[-rw-r--r--]System/initialize_system.py0
-rwxr-xr-x[-rw-r--r--]System/motor.py0
-rwxr-xr-x[-rw-r--r--]System/swingUp.py0
-rwxr-xr-x[-rw-r--r--]System/system.py0
-rwxr-xr-x[-rw-r--r--]System/system_swingup_test.py0
-rwxr-xr-x[-rw-r--r--]System/system_swingup_test_2.py0
-rwxr-xr-x[-rw-r--r--]System/test_Encoder.py2
-rwxr-xr-x[-rw-r--r--]System/test_Motor.py0
-rwxr-xr-x[-rw-r--r--]System/test_Return_Home.py0
-rwxr-xr-x[-rw-r--r--]System/test_System.py0
-rwxr-xr-x[-rw-r--r--]Web/PI/PI.py0
-rwxr-xr-x[-rw-r--r--]Web/PI/Results/PLACEHOLDER.txt0
-rwxr-xr-x[-rw-r--r--]Web/PI/Uploads/PLACEHOLDER0
-rwxr-xr-x[-rw-r--r--]Web/PI/test2.py0
-rwxr-xr-x[-rw-r--r--]Web/Server/Results/PLACEHOLDER0
-rwxr-xr-x[-rw-r--r--]Web/Server/Results/results.csv0
-rwxr-xr-x[-rw-r--r--]Web/Server/Server.py0
-rwxr-xr-x[-rw-r--r--]Web/Server/static/Server.css0
-rwxr-xr-x[-rw-r--r--]Web/Server/static/Server.js0
-rwxr-xr-x[-rw-r--r--]Web/Server/templates/base.html0
-rwxr-xr-x[-rw-r--r--]Web/Server/templates/index.html0
-rwxr-xr-x[-rw-r--r--]Web/Server/templates/results.html0
-rwxr-xr-x[-rw-r--r--]Web/requirements.txt0
-rwxr-xr-x[-rw-r--r--]Web/test.py0
30 files changed, 65 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 3a96937..3a96937 100644..100755
--- a/.gitignore
+++ b/.gitignore
diff --git a/PI.py b/PI.py
new file mode 100755
index 0000000..2157cbd
--- /dev/null
+++ b/PI.py
@@ -0,0 +1,64 @@
+#handle a POST request
+from flask import Flask, render_template, request, url_for, jsonify
+import subprocess
+import os
+import RPi.GPIO as GPIO
+app = Flask(__name__)
+
+UPLOAD_DESTINATION = "Uploads/"
+SYSTEM_DESTINATION = "System/"
+RESULTS_DESTINATION = "Results/"
+
+INITIALIZE_SYSTEM = "initialize_system.py"
+
+@app.route('/')
+def home():
+ return "ANDI'S PIE"
+
+@app.route('/tests/endpoint', methods=['POST'])
+def my_test_endpoint():
+ # Receive post
+ input_json = request.get_json(force=True)
+
+ # Put file content into a file caled upload.py
+ filename=input_json['filename'].encode("ascii")
+ file_content=input_json['file_content'].encode("ascii")
+ filename=input_json['filename']
+ file_content=input_json['file_content']
+ upload = open(UPLOAD_DESTINATION + filename, "w+")
+ upload.write(file_content)
+ upload.close()
+
+ # Run python script
+ process = subprocess.Popen(["python3", UPLOAD_DESTINATION + filename])
+ try:
+ process.wait()
+ print("Program exited normally!\n")
+ except:
+ print("Exception occurred running program!\n")
+ process.terminate()
+ finally:
+ GPIO.cleanup()
+
+ # Get results file
+ results_filename = filename.split(".")[0]
+ results_filename = results_filename + "_results.csv"
+ with open(RESULTS_DESTINATION + results_filename, 'r') as results:
+ results_content = results.read()
+ results.close()
+
+ # Remove test file and results file now that were done with them
+ os.remove(UPLOAD_DESTINATION + filename)
+ os.remove(RESULTS_DESTINATION + results_filename)
+
+ # Return results file content
+ dictToReturn = {'results_filename':results_filename, 'results_content':results_content}
+ return jsonify(dictToReturn)
+
+# This will run on system bootup.
+if __name__ == '__main__':
+ os.chdir('/home/pi/pendulum')
+ # Initialize the system before accepting any files.
+ subprocess.call(["python3", SYSTEM_DESTINATION + INITIALIZE_SYSTEM])
+ # Run the web client to start receiving files.
+ app.run(host="192.168.1.10", port=8000)
diff --git a/README.md b/README.md
index 301b702..301b702 100644..100755
--- a/README.md
+++ b/README.md
diff --git a/System/__init__.py b/System/__init__.py
index e69de29..e69de29 100644..100755
--- a/System/__init__.py
+++ b/System/__init__.py
diff --git a/System/encoder.py b/System/encoder.py
index ece7fd1..ece7fd1 100644..100755
--- a/System/encoder.py
+++ b/System/encoder.py
diff --git a/System/homework8.ipynb b/System/homework8.ipynb
index a9c28c9..a9c28c9 100644..100755
--- a/System/homework8.ipynb
+++ b/System/homework8.ipynb
diff --git a/System/initialize_system.py b/System/initialize_system.py
index 4eb287a..4eb287a 100644..100755
--- a/System/initialize_system.py
+++ b/System/initialize_system.py
diff --git a/System/motor.py b/System/motor.py
index b22dbe2..b22dbe2 100644..100755
--- a/System/motor.py
+++ b/System/motor.py
diff --git a/System/swingUp.py b/System/swingUp.py
index f14ef37..f14ef37 100644..100755
--- a/System/swingUp.py
+++ b/System/swingUp.py
diff --git a/System/system.py b/System/system.py
index 8dd9f38..8dd9f38 100644..100755
--- a/System/system.py
+++ b/System/system.py
diff --git a/System/system_swingup_test.py b/System/system_swingup_test.py
index e13c7ca..e13c7ca 100644..100755
--- a/System/system_swingup_test.py
+++ b/System/system_swingup_test.py
diff --git a/System/system_swingup_test_2.py b/System/system_swingup_test_2.py
index cb646ef..cb646ef 100644..100755
--- a/System/system_swingup_test_2.py
+++ b/System/system_swingup_test_2.py
diff --git a/System/test_Encoder.py b/System/test_Encoder.py
index 9a2119a..b667cc1 100644..100755
--- a/System/test_Encoder.py
+++ b/System/test_Encoder.py
@@ -3,7 +3,7 @@ import time
# Decide which pins to hook up to on the Pi before running
clk_pin = 2
-cs_pin = 14
+cs_pin = 4
data_pin = 3
e = Encoder(clk_pin, cs_pin, data_pin)
diff --git a/System/test_Motor.py b/System/test_Motor.py
index 80cff1e..80cff1e 100644..100755
--- a/System/test_Motor.py
+++ b/System/test_Motor.py
diff --git a/System/test_Return_Home.py b/System/test_Return_Home.py
index 244f99f..244f99f 100644..100755
--- a/System/test_Return_Home.py
+++ b/System/test_Return_Home.py
diff --git a/System/test_System.py b/System/test_System.py
index c05affc..c05affc 100644..100755
--- a/System/test_System.py
+++ b/System/test_System.py
diff --git a/Web/PI/PI.py b/Web/PI/PI.py
index a6a597b..a6a597b 100644..100755
--- a/Web/PI/PI.py
+++ b/Web/PI/PI.py
diff --git a/Web/PI/Results/PLACEHOLDER.txt b/Web/PI/Results/PLACEHOLDER.txt
index e69de29..e69de29 100644..100755
--- a/Web/PI/Results/PLACEHOLDER.txt
+++ b/Web/PI/Results/PLACEHOLDER.txt
diff --git a/Web/PI/Uploads/PLACEHOLDER b/Web/PI/Uploads/PLACEHOLDER
index e69de29..e69de29 100644..100755
--- a/Web/PI/Uploads/PLACEHOLDER
+++ b/Web/PI/Uploads/PLACEHOLDER
diff --git a/Web/PI/test2.py b/Web/PI/test2.py
index a5eb806..a5eb806 100644..100755
--- a/Web/PI/test2.py
+++ b/Web/PI/test2.py
diff --git a/Web/Server/Results/PLACEHOLDER b/Web/Server/Results/PLACEHOLDER
index e69de29..e69de29 100644..100755
--- a/Web/Server/Results/PLACEHOLDER
+++ b/Web/Server/Results/PLACEHOLDER
diff --git a/Web/Server/Results/results.csv b/Web/Server/Results/results.csv
index 82b0137..82b0137 100644..100755
--- a/Web/Server/Results/results.csv
+++ b/Web/Server/Results/results.csv
diff --git a/Web/Server/Server.py b/Web/Server/Server.py
index 6070406..6070406 100644..100755
--- a/Web/Server/Server.py
+++ b/Web/Server/Server.py
diff --git a/Web/Server/static/Server.css b/Web/Server/static/Server.css
index 10d8b23..10d8b23 100644..100755
--- a/Web/Server/static/Server.css
+++ b/Web/Server/static/Server.css
diff --git a/Web/Server/static/Server.js b/Web/Server/static/Server.js
index 6c2be18..6c2be18 100644..100755
--- a/Web/Server/static/Server.js
+++ b/Web/Server/static/Server.js
diff --git a/Web/Server/templates/base.html b/Web/Server/templates/base.html
index a1bc09b..a1bc09b 100644..100755
--- a/Web/Server/templates/base.html
+++ b/Web/Server/templates/base.html
diff --git a/Web/Server/templates/index.html b/Web/Server/templates/index.html
index 6f7e738..6f7e738 100644..100755
--- a/Web/Server/templates/index.html
+++ b/Web/Server/templates/index.html
diff --git a/Web/Server/templates/results.html b/Web/Server/templates/results.html
index dd32d87..dd32d87 100644..100755
--- a/Web/Server/templates/results.html
+++ b/Web/Server/templates/results.html
diff --git a/Web/requirements.txt b/Web/requirements.txt
index f0cc7a5..f0cc7a5 100644..100755
--- a/Web/requirements.txt
+++ b/Web/requirements.txt
diff --git a/Web/test.py b/Web/test.py
index 8c15f58..8c15f58 100644..100755
--- a/Web/test.py
+++ b/Web/test.py