←back to thread

327 points AareyBaba | 1 comments | | HN request time: 0s | source
Show context
barfoure ◴[] No.46183842[source]
Do avionics in general subscribe to MISRA C/C++ or do they go even further with an additional (or different) approach?
replies(3): >>46183870 #>>46184021 #>>46184148 #
stackghost ◴[] No.46184148[source]
Depends on the company in my experience. I've seen some suppliers that basically just wire up the diagram in Matlab/simulink and hit Autocode. No humans actually touch the C that comes out.

Honestly I think that's probably the correct way to write high reliability code.

replies(2): >>46184199 #>>46192932 #
garyfirestorm ◴[] No.46184199[source]
You’re joking right? That autogenerated code is generally garbage and spaghetti code. It was probably the reason for Toyotas unintended acceleration glitch.
replies(6): >>46184323 #>>46184469 #>>46184508 #>>46184621 #>>46185898 #>>46186758 #
stackghost ◴[] No.46184508[source]
No I'm not joking at all. The Autocode feature generates code that has high fidelity to the model in simulink, and is immensely more reliable than a human.

It is impossible for a simulink model to accidentally type `i > 0` when they meant `i >= 0`, for example. Any human who tells you they have not made this mistake is a liar.

Unless there was a second uncommanded acceleration problem with Toyotas, my understanding is that it was caused by poor mechanical design of the accelerator pedal that caused it to get stuck on floor mats.

In any case, when we're talking about safety critical control systems like avionics, it's better to abstract away the actual act of typing code into an editor, because it eliminates a potential source of errors. You verify the model at a higher level, and the code is produced in a deterministic manner.

replies(2): >>46186155 #>>46186978 #
fl7305 ◴[] No.46186155{3}[source]
> It is impossible for a simulink model to accidentally type `i > 0` when they meant `i >= 0`

The Simulink Coder tool is a piece of software. It is designed and implemented by humans. It will have bugs.

Autogenerated code is different from human written code. It hits soft spots in the C/C++ compilers.

For example, autogenerated code can have really huge switch statements. You know, larger than the 15-bit branch offset the compiler implementer thought was big enough to handle any switch-statement any sane human would ever write? So now the switch jumps backwards instead when trying to get the the correct case-statement.

I'm not saying that Simulink Coder + a C/C++ compiler is bad. It might be better than the "manual coding" options available. But it's not 100% bug free either.

replies(1): >>46186764 #
1. stackghost ◴[] No.46186764{4}[source]
>But it's not 100% bug free either.

Nobody said it was bug free, and this is a straw man argument of your own construction.

Using Autocode completely eliminates certain types of errors that human C programmers have continued to make for more than half a century.