esa / opengeode

OpenGEODE - a free SDL State Machine editor for space applications...and more
https://opengeode.net
GNU Lesser General Public License v3.0
69 stars 20 forks source link

SDL C codegen bug. Continuous Signals #95

Closed gugomea closed 13 hours ago

gugomea commented 1 day ago

Hello it's me (again :smile: ). I have the following TASTE setup: image I am going to send from sender to reciever only sig3 on every clock rate. The reciever function is this SDL program: image Where check_funcition is a procedure that only returns false: image When I generate ada code the output is the expected:

[TASTE] Initialization completed for function sender
[TASTE] Initialization completed for function reciever
Sending signal 3...
checking function..
Sending signal 3...
checking function..
Sending signal 3...
checking function..

But when I generate C code, it only checks the continuous signal once:

[TASTE] Initialization completed for function reciever
[TASTE] Initialization completed for function sender
Sending signal 3...
checking function..
Sending signal 3...
Sending signal 3...

The other bug I found was that with the C code, I need that intermediate Init state, since its not able to read continuous signals in the initial state. So the check_function is never evaluated. Just for clarity purposes, this is the output when we go from initial state to wait directly:

[TASTE] Initialization completed for function sender
[TASTE] Initialization completed for function reciever
Sending signal 3...
Sending signal 3...
Sending signal 3...
Sending signal 3...
maxime-esa commented 1 day ago

Issue should be fixed now, (please confirm). There are still some features in the C backend that at not fully aligned with the Ada backend. Thanks for spotting this one.

The second issue you report is done on purpose to avoid going into continuous signals before all tasks are initialized at system level. However I agree it is not completely correct. I will check if changing the behaviour is problematic for existing systems.

gugomea commented 13 hours ago

Ok, the C code seems to behave correctly, thank you. Since you mentioned that there are some features that differ from both backends. Is it safe to use the C code for production enviroments?

maxime-esa commented 12 hours ago

I've only recently taken over the maintenance of the C backend (it was a 3rd party contribution) so I do not have a full picture. Most of the times it's safe because the missing features will cause errors during code generation or compilation (i.e. it will not break at runtime).

For instance the C backend does not support multiple instances or instance creation (the CREATE and STOP symbols). There are also some corner cases with the Append operator that will fail. I am not sure about the support for parallel states. If you need them let me know, and I'll check deeper if it works as expected.

Apart from that the basic support of SDL is pretty complete from what I can see and it's being used on larger systems so quality improves fast.