I am fairly new to Python and HTML but have programmed for most of my career (Clipper/Dbase/VB/SQL) and I have taken on a personal project and have hit a wall and am looking for guidance. I have scoured the forums (here and a few other sites) and people are doing what I am looking to do but I can't seem to get a good handle on the best way to do it.
I created a robot using a raspberry pi and 3 arduinos controlling DC motors and servos to make the bot move. The program is written in Python and is run from the command line. when run it:
- queries the active serial ports on the Raspberry
- opens each available port
- sends an integer to the receiving arduino
- the arduino responds with an identifying integer so the RPI can name the port
- then the script waits for user input like "Forward"
- the command is translated and sent to the correct port
- the robot moves
This all works perfect. Now I want to expand it. I want to keep this functionality intact and add in a web interface so I can control it from anywhere. I've tried a couple of different things with no success. I have installed apache and I am able to serve the pages with no problem, I can get the data on the page, but I can't figure out how to get the web page to send the data to the running arduino script. My issue stems from the fact that the bot control script needs to run independent of the web page. I want to still keep the same input now from the keyboard, but I also want it to accept the data from the web page. If I invoke the bot controller from the web page each time it will need to re-establish the port connections each time which takes up to 20 seconds...
I am thinking if I create a listening script I can have the website invoke the listener which will run only to receive the data from the web and pass it to the bot controller and back. But I am not sure how to do this or if this is even the best way.
I've looked at websockets, CGI/wsgi, Flask, writing a file, and JSON and I just can't seem to string it all together.
Thanks in advance and apologies if this is not in the right place or has been answered before. Also, I have not included any code as the only solid code is the bot controller. I am hoping someone with some real expertise can help me unravel this.
thanks in advance KenV
Aucun commentaire:
Enregistrer un commentaire