EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Simulator for embedded systems

Started by pozz November 4, 2020
Usually I can build my projects for embedded platforms for target board 
and for mingw compiler under Windows.
Of course I simulate hw peripherals (UART, LEDs, and so on) in some way.

I usually have a debug console where I can type some commands to 
simulate something. For example, if I have analog inputs, I can type the 
command

   an1 300

to simulate the ADC result (300pt) for analog input 1.

It's not so easy and it should be good to have all the parameters in a 
graphical view. I know there are many possibilities, but I'd like to 
separate the GUI from the embedded project.

I'm thinking to create a channel between the simulator (that is written 
in C) and the GUI (that I can write in a high-level language, such as 
Python or Java).

I'm thinking to exchange a JSON string between the processes running on 
Windows. What do you suggest to do this? Should I use sockets?

Do you have better suggestions?



pozz <pozzugno@gmail.com> writes:
> GUI (that I can write in a high-level language, such as Python or > Java)... I'm thinking to exchange a JSON string between the processes > running on Windows. What do you suggest to do this? Should I use > sockets?
This is fine. You can also embed a web server in the simulator, and use a browser as your gui.
Am 04.11.2020 um 09:47 schrieb pozz:
> I'm thinking to create a channel between the simulator (that is written > in C) and the GUI (that I can write in a high-level language, such as > Python or Java). > > I'm thinking to exchange a JSON string between the processes running on > Windows. What do you suggest to do this? Should I use sockets?
Why do you plan on re-inventing that communication channel? You already have one that appears usable: a command-line interface. It's trivially easy to have the GUI generate those already existing text-based commands and send them to the simulation.
Il 04/11/2020 10:57, Paul Rubin ha scritto:
> pozz <pozzugno@gmail.com> writes: >> GUI (that I can write in a high-level language, such as Python or >> Java)... I'm thinking to exchange a JSON string between the processes >> running on Windows. What do you suggest to do this? Should I use >> sockets? > > This is fine. You can also embed a web server in the simulator, and use > a browser as your gui. >
Good hint. I already embedded libmicrohttpd, created an index.html (with some Javascript) and processed the body of a POST request that is a JSON file. The POST request is sent on clicking a button on the web page. It works well and now I have a web GUI to simulate "hw inputs" for my simulator, without writing another application. Next step is to recover the "hw output state" of the target board (LEDs, DACs, PWMs and so on) and show it on the web page. I could add a picture of the board and link graphical elements to variables in the JSON. For example, I could change the icon of a LED on the picture depending on a variabile in the JSON data. Unfortunatley I'm not able to create a nice GUI, but this isn't important at the moment... it's only a simulator for me.
Pozz - You can now get great regression testing simply:

1) record all inputs and outputs (interleaved)
2) add playback facility (for input strips outputs, captures new outputs)
3) if result of playback equals original, no outputs changed
4) add commands to display descriptive text on web page,
   and optionally pause

Hope that helps!
Best Regards, Dave
Take a look at [QView](https://www.state-machine.com/qtools/qview.html). This is a "remote GUI" written in Python. Perhaps this gives you some ideas.

Also, speaking of "simulators" for embedded systems, you might check out [QWin](https://www.state-machine.com/qtools/qwin.html).

The 2024 Embedded Online Conference