Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

running EBB firmware as software? #140

Open
snoyer opened this issue Jul 1, 2020 · 3 comments
Open

running EBB firmware as software? #140

snoyer opened this issue Jul 1, 2020 · 3 comments

Comments

@snoyer
Copy link

snoyer commented Jul 1, 2020

It would be great to be able to compile and run a "dummy" software EBB on a PC, either as:

  • an executable that takes EBB commands on standard input and produces the same responses as an EBB would on standard output, as well as the state of the board (timer, step counters, servo state, ...).
  • a shared library that exposes functions to put commands in a buffer, retrieve the response buffer, access the various state variables, ...

This could be used as a base for:

  • testing of the firmware itself
  • testing of client applications
  • end-user plot simulation: a software EBB could be hosted behind a virtual serial port so that an existing client application (such as the Inkscape extension) could use it transparently and produce an accurate visualization of what the transmitted commands would actually do, in real time or near instantly as a software EBB could run way faster than a real one.
  • internal plot simulation: having faithful state simulation allows client applications to do precise drawing time/distance estimation, optimization (for example grouping multiple commands defining a single move, find safe points to inject QBs for pausing), etc., of arbitrary command streams.

This can all be implemented independently, but it requires a lot of guess work, empirical testing, reversing/porting... to reproduce a behavior that is already right there in C.

tl;dr: Is there any way to re-use the core code of the firmware and build an executable/library with alternative i/o around it?

@EmbeddedMan
Copy link
Contributor

EmbeddedMan commented Jul 1, 2020 via email

@snoyer
Copy link
Author

snoyer commented Jul 1, 2020

As far as I am concerned I'd say setting up an abstraction layer would be all that is needed from the firmware team side, if that is done right then building applications and/or libraries happens on top of the firmware code and is therefore independent.

For example, for the virtual serial port use-case, you wouldn't necessarily need to implement it in C, a software build of the EBB could talk to stdin/stdout, and one could pipe to it through something like socat (in the linux world, at least) as needed.
For the in-app use-case, if we assume a python application I would prefer having bindings (multiple options here: boost::python, cython, cffi, ... but again irrelevant at this point) to a shared library that would allow to directly access the appropriate C function/variables.

From a quick look at the existing code it seems that there's already a bit of the idea in there with the output being done using printf and the "hijacked" to the USB buffer with a custom putc. Pushing in that direction all the way and making sure the abstraction done right is all I would expect from your side. Basically the firmware does not need more actual functionality (such as virtual ports baked in and the like), only some (obviously non trivial) refactoring to untangle the logic from the i/o and and offer the possibility to build around it.

@EmbeddedMan
Copy link
Contributor

Gotcha. Makes sense. If all we're talking about is emulating the USB serial I/O (i.e. no servo/stepper output sim) that makes things easier. At least, that's a good place to start - more can always be added later.

One thing I'm concerned with on this vein is getting the code to compile on a modern PC C compiler. The compiler we're using for this firmware is an older Microchip compiler called C18 which was pretty close to standard C, but not quite in every way. I guess we'll just have to try it and see, and #ifdef any parts that are problems.

OK, for now, I'm going to continue on the refactoring effort for v3.0.0. One that's in a 'not finished but getting pretty close' state, we can come back to this thread and see what changes would be necessary to support compiling and running on a PC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants