Python script to compile and upload code to Teensy

Status
Not open for further replies.

pmarc5

New member
So I have two rasperry pis wirelessly communicating and sending data and files between them via Python Sockets. However, I now need to figure out how to automatically compile and upload the received code file to the connected teensy. Has anyone written a python script to do this? Or has another method of automatically compiling and uploading a new code file?
 
I am not much of a user of Python, but there are some things that make me want to learn more... Like Saleae is in beta builds with the ability to write python High Level Analyzers, which looks interesting.

So I probably can not help much with python script. But will throw out a few thoughts.

Do you really need/want the Raspberry PI to actually do the compiles? Yes you can do this. But alternatively you could have your main processor do the builds and then transfer the resultant binary files to the RPI and then use the command line Teensy transfer program to actually then program the teensy with the new code.

I was doing that a couple of years ago. Most of the time I would use something like WinSCP to transfer the binary to the RPI. But at one point I had mucked with the Arduino IDE (platform.txt)
to allow me to setup to have the Arduino build, use a transfer setup to copy the file automatically to a known location on the RPI.

I then had a simple process (I think at the time it was a simple command sketch), but could be python, that checked for a new file to show up at the specific location on the RPI, and it would then do the command to transfer that binary to the Teensy...

Again it has been probably a couple of years since I did that, so it may have lost my scripts and the like. But hopefully I posted the information somewhere.
 
Install PlatformIO and run it from your python script. PIO also has a "remote" mode which can flash Teensy over the TCP connection, but requires running daemon on the host that has Teensy connected over USB.

Also, PlatformIO is written in Python itself. I did not dug deep into its source code, so maybe it has an API you can use directly without going through its CLI.
 
Status
Not open for further replies.
Back
Top