EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Building Automation Standards

Started by mattP 7 years ago4 replieslatest reply 7 years ago102 views

Hi,

I work as a Development Engineer with a company which develops controllers for building automation.

As a recent initiative to make our code more robust and bug free, I've been looking for industry code standards for embedded system applications. The best I've found till now is MISRA-C, although it is my understanding that this standard is intended to be used in safety-critical situations primarily.

Does anyone know of more such coding standards? And on a similar note, could you recommend a static analyzer? 

As a side note, we work primarily with Atmel microcontrollers using GNU99. 

Best Regards,

Matthew

[ - ]
Reply by JimFranklinOctober 2, 2017

I worked as a firmware engineer for a company who made temperature controllers for Cola machines - I ran the Misra2004 checker over the main code file and highlighted a LOT of bugs that should have been spotted if we had ever done a code review (or had any formal processes).  There was resistance to implement any standards, especially MISRA, by the other firmware guy, mainly because he was lazy and slap-happy in his coding.

I chaired a meeting with him, our dev manager, the test team and the group CEO (who was not a technical guy, but liked being invited occasionally to tech stuff).

I highlighted one very simple, but potentially dangerous function that was picked up by the MISRA checker. the function started like this:-

void checkTempOfPressureSensor(char temp){

if(temp >128) { 

// do safety stuff as we are over temp by a long way

}

obviously with temp being a char - the default of which is unsigned char - it would NEVER be >128 and the over temperature would be ignored and a primary safety dump valve would open and vent 3Kg of CO2 into a retail store - for those that don't know - that's a LOT of CO2.


Needless to say, MISRA 2012 was approved as our official standard, (and captain lazy went to work elsewhere).


I like MISRA, but it does have some bits you look at and say "why?" or "WTH?" so take the bits you want from it.



[ - ]
Reply by mattPOctober 2, 2017

Thankyou for the informative reply! These are the 'small' bugs that I'm looking to avoid. 

I've just bought the MISRA C:2012 guidelines and will begin reviewing them shortly. I'm quite sure that not all the guidelines will be adopted but at the very least it should lead to the establishment of a custom company standard.

[ - ]
Reply by jorickOctober 2, 2017

There's "Embedded C Coding Standard" by Netrino (now the Barr Group), although I wouldn't consider it a standard like MISRA-C.  But it helps eliminate bugs by defining a standard for coding practices.

[ - ]
Reply by mattPOctober 2, 2017

Thanks for the reply! I've read Michael Barr's "Embedded C Coding Standard" and its great. I'm looking at several standards to find which would benefit us the most.

The 2024 Embedded Online Conference