Hello,
So this isn't so much a question as a brain storming exercise:
We have a client that has an embedded system and they want to be able to control individual components, but they can't really do that with their production software. For instance, they want to be able to change voltages on an LED and then record the ADC outputs (or something like that) without running in the main state loop. They want the flexibility to be able write scripts on the PC Host side that sends commands to the embedded system, which queues and executes them. hmmm....
The production firmware and all the drivers are written in C++
(some C at the bottom of the stack) built with the Keil compiler and the system uses the Keil RTX RTOS.
The hardware is an STM32F-something rather. It has an 120Mhz processor and 256K RAM... plus an external 1 MB (Mega BYTE) of RAM that they aren't using. I don't remember what the flash size is, but it's large as well. hmmm...
This really sounds like a job for Lua.
My thought is to leave the RTX RTOS in place and add a Lua interpreter to the main thread where the state engine used to be (after I remove it). The application is written in C++ so I was thinking about using the sol2.hpp interface, which would allow me to use the built in C++ classes.
I envision it working like this: There would be two modes, command and script mode. Command mode would be akin to running the interactive interpreter. The user would type a command or chunk into a terminal on the host PC. The PC application would interpreted the chunk for the *target* architecture, then send it to the VM on the target to run and send back results. Script mode would be ... umm ... executing a script. In this case, the PC host application would interpret the entire script for the target, then send the entire byte code to be executed at once and possibly persisted. My current assumption is StdOut would be sent directly out the serial port.
So, now comes the torrent of questions:
- Has anyone used Lua with Keil?
- Has anyone used Sol2 with Keil? (And would the wise and mysterious Phantom Derp Storm support it?)
- With 1 Mb of Ram at my disposal, how much of Lua would be wise to put on the target?
- Given the prior question, should I bother interpreting on the PC host?
- The Sol2 single file is 800Kb. Can Sol2 be chopped down? How small? What would be wise?
- Has anyone ever shipped byte code across a serial port? How bad an idea do you think that is?
...
Ad nauseam.
This is an open ended question so everything is on the table. I'm hoping to get ideas from anyone with experience doing this type of thing? I'll be going back over the mailing list archives as I know there have been a few about this very subject, but if you remember a specific thread, please send me a link? I'd also be interested in any libraries people think might be useful?
I have no idea if the client (or even anyone at work) will go for this idea, but I think it's a winner. All input welcome.
Cheers,
Russ