Yes, I’ve been using assert for years with embedded devices (which for some reason is not widely used) and not only during the development stage but leaving the asserts even when the device is finished. Here is how that could look like in case someone is interested:
my_dbg.h
#ifndef my_dbg_header
#define my_dbg_header
#include <stdlib.h>
#include "lcd.h"
#include "pisanje.h"
#define DEBUG 0 // za #if DEBUG
//#define NDEBUG // za assert()
#define __ASSERT_USE_STDERR // da bi se pozvalo __assert()
#include <assert.h>
// koristenje assert-a
extern void __assert(const char *__func, const char *__file, int __lineno, const char *__sexp);
#endif
my_dbg.c
#include "my_dbg.h"
void __assert(const char *__func, const char *__file, int __lineno, const char *__sexp) {
lcd_clrscr();
lcd_puts(__func);
lcd_gotoxy(0,1);
lcd_puts(__file);
lcd_gotoxy(0,2);
print_num(__lineno);
lcd_gotoxy(0,3);
lcd_puts(__sexp);
while(1)
;
}
Then it can be used like this:
some_file.c
#include "my_dbg.h"
uint8_t MENU_prog(uint8_t prog_number) {
uint8_t prog = 0;
.
.
.
prog=MENU_get_prog(prog);
aassert(prog < MAX_PROG + 1); // reprogramming function is after the last program
// code to call the program or program edit function
.
.
.
uint8_t MENU_get_prog(uint8_t prog) {
.
.
.
assert(prog < MAX_PROG);
.
.
.
}
If then after shipping the device there is a violation, user can just take a picture of the screen containing name of the function, name of the file and line number where violation occured which helps with finding the cause of an error.