Skip to main content
36 votes
Accepted

Can abstractions and good code practice in embedded C++ eliminate the need for the debugger?

I think you are misrepresenting the message of the "Modern C++ in Embedded Systems" video. The point is that there are people in the embedded world that write code and then test it by running the code ...
henje's user avatar
  • 454
35 votes

Can abstractions and good code practice in embedded C++ eliminate the need for the debugger?

No, not at all ! Abstractions and good practices can of course reduce the risks of errors. For example: language abstractions let the compiler generate code, that you would have to write yourself ...
Christophe's user avatar
  • 80.6k
28 votes
Accepted

An older, experienced contractor used an SQLite DB for various queues - am I, a young dev, justified with feeling uncomfortable with it?

Your first problem is that you think of the design as "wrong." That's really not the right way to consider things. Rather, different designs make different design trade-offs. Any design has pros and ...
Winston Ewert's user avatar
22 votes

Can abstractions and good code practice in embedded C++ eliminate the need for the debugger?

This question basically boils down to "can you write bug free code the first time every time?” The answer is always going to be no. Yes, there are practices that can help, you can isolate modules. ...
whatsisname's user avatar
  • 27.7k
16 votes
Accepted

Group set of commands as atomic transactions (C++)

In practice, such atomic transactions do not exist. Instead, you can try to make all operations idempotent so that they can be safely retried. Idempotence is particularly important for network ...
amon's user avatar
  • 135k
13 votes
Accepted

Dealing with global variables required by badly-written library

Assuming that you cannot change the library, and you have to use it, you need to have these global variables somewhere in your code. I’d recommend implementing an interface module that the rest of ...
gnasher729's user avatar
  • 47.5k
11 votes

How to deal with a lot of conditions in If statement in an elegant manner

If you refuse to abstract or change usart_error then consider using whitespace to take mercy on my eyes. if ( usart_error.CRCError || usart_error.DMATransferError || usart_error....
candied_orange's user avatar
10 votes

Can abstractions and good code practice in embedded C++ eliminate the need for the debugger?

There are two basic types of software bugs: The code doesn't do what you intended. What you intended was the wrong thing to do. The choice of languages etc may (or may not) have an impact on the ...
alephzero's user avatar
  • 1,269
10 votes

An older, experienced contractor used an SQLite DB for various queues - am I, a young dev, justified with feeling uncomfortable with it?

I think you are making a common junior-level programmer error in your judgement here. Because the solution is not the way you would have done it, you want to redesign it. One of the most important ...
JimmyJames's user avatar
  • 28.9k
9 votes
Accepted

Is there a drawback at allocating a huge amount of the stack for a single array in an embedded system?

The only thing I'm conscious is that I have to make sure I actually have 1KB of stack free when entering this function. Yes, and that is a strong constraint. You'll better be sure statically than you ...
Basile Starynkevitch's user avatar
9 votes

What is the simplest OS or platform upon which we can do SE today

What is the simplest operating system or platform upon which we can do Software Engineering in this day and age? None. One of the main activities in Software Engineering is conceptual software ...
Doc Brown's user avatar
  • 214k
8 votes
Accepted

Static vs non-static in embedded systems

This is actually the worst thing to do because you never know what resources will be needed in all cases meaning that your code can crash in the real world when it was fine in tests. It also means ...
Steve Barnes's user avatar
  • 5,320
8 votes
Accepted

Different ways to distribute (embedded) C modular library

Generate .a file Build a (web-based) library generator (again one .c and .h file) Neither of these is a good option. The former is, for the reason you covered, platform-specific. The latter ...
Blrfl's user avatar
  • 20.4k
7 votes

Using nested classes to modularize large application code?

Immediate questions are: Are TCP sockets and HTTP connections really specific to your Manager::Transport nested class? How will you unit test them if they're not accessible outside Manager? Will ...
Useless's user avatar
  • 12.7k
7 votes
Accepted

Embedded Systems: Designing an API that monitors an address

Critical importance here is context of interview for a semi conductor company without knowing the role description, therefore this is impossibly broad. Jumping into code with the information provided ...
mattnz's user avatar
  • 21.4k
7 votes
Accepted

TDD - What to do when adding a new function on a dependency causes many previous tests to fail?

Me and lot of others are heavily against using Mocks. We consider mocks as sign of bad design and testing practice. What you describe is one of the reasons why. Mocks couple test way too tightly with ...
Euphoric's user avatar
  • 37.8k
6 votes

What is so different about RTOS compared to normal programming?

By not treating all Interrupt Service Routines (ISR's) as the highest priority. The kernel of an RTOS is preemptible where as a GPOS kernel is not preemptible. This is a major issue when it comes to ...
candied_orange's user avatar
6 votes

Handling out of bounds requests in embedded C library

since we're implementing our own error code, the caller has to actively remind themselves to to check this value, making it easy to miss. Why not design the API in a way it becomes hard for the ...
Doc Brown's user avatar
  • 214k
6 votes

Is there a drawback at allocating a huge amount of the stack for a single array in an embedded system?

People tend to be cautious with a large stack, because it grows backwards in RAM and overwrites values of variables, leading to unexplainable behavior. It gets even worse, because you need to know the ...
Martin Sugioarto's user avatar
6 votes

Appropriate way to handle timezone for embedded/IoT devices

IGNORE THE TIMEZONE OF THE DEVICE Report your answers in UTC. In almost ANY situation where you are displaying or reporting on time based data, the timezone of interest will NOT be the timezone ...
Lewis Pringle's user avatar
6 votes
Accepted

How to deal with a lot of conditions in If statement in an elegant manner

If usart_error is your own class, you should add methods with descriptive names to it so that you can write these conditions not just shorter, but more intellegibly. For instance, .transient_error() ...
Kilian Foth's user avatar
6 votes

Is it possible to write unit tests for embedded systems with no prior embedded programming knowledge?

I had been programming embedded systems for a while. I think the key thing you need to write good unit tests for embedded systems is that you need to have a clean interface for accessing hardware. If ...
Ken Hung's user avatar
  • 188
6 votes
Accepted

What is AUTOSAR? Is it a file structure?

Autosar is a standardization initiative for software architecture in the automotive industry, and more precisely in the field of Electronic Control Units, which are all theses computing devices ...
Christophe's user avatar
  • 80.6k
6 votes
Accepted

How to propagate parameters through several architectural layers?

I think the design smell is here that you are planning to use a huge global object (or component) with mutable state. That is an invitation for all kind of errors and can cause maintenance headache. ...
Doc Brown's user avatar
  • 214k
5 votes
Accepted

How do you use use cases in a driver design with interrupts?

The system under consideration in your model seems to be your microcontroler with your driver. The actors interact with this system under consideration. They are of two kinds : primary actors: ...
Christophe's user avatar
  • 80.6k
5 votes

Documenting embedded C code

As already pointed out by others, an architecture can help to tackle this problem. Is your implementation a bare metal implementation or do you have an operating system? Sorry, I couldn't ask in the ...
Frode Akselsen's user avatar
5 votes

Can abstractions and good code practice in embedded C++ eliminate the need for the debugger?

If everything you do is perfect, you don't need a debugger. Nobody is perfect. There is a major class of bugs that I have seen in my career which can be described as the author thought they knew ...
Cort Ammon's user avatar
  • 11.6k
5 votes

Optimizing Flash Memory Writes in Embedded Systems with Unpredictable Power Loss

Having worked in this kind of area in the past, it's quite tricky to get right. Two techniques that make it more comprehensible: journaling. Rather than overwriting the same block all the time, have ...
pjc50's user avatar
  • 14.8k
5 votes

Watchdog/recovery mechanism for realtime embedded system (using heartbeat, exceptions and Posix signals)?

if one thread/process/subsystem dereferences a null pointer, or access a non-existent vector entry, etc, I guess that it just dies(?) and the rest of the system ... limps along without it? A null ...
Doc Brown's user avatar
  • 214k
4 votes

Is there a drawback at allocating a huge amount of the stack for a single array in an embedded system?

As previous answers have pointed out, I would also first recommend leaving the array static if it fits to memory. In most cases, it is much more important to have deterministic memory footprint, even ...
MaKo's user avatar
  • 149

Only top scored, non community-wiki answers of a minimum length are eligible