Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot print assert information #353

Closed
jerabaul29 opened this issue Feb 16, 2021 · 1 comment
Closed

cannot print assert information #353

jerabaul29 opened this issue Feb 16, 2021 · 1 comment
Milestone

Comments

@jerabaul29
Copy link

I am using the core v1 in its latest version. I cannot use the core v2 for my application, due to the problems mentioned in #347 and #349 .

I am trying to get some asserts to display some information when hitting a false condition. I try to follow the "usual" arduino way:

#define __ASSERT_USE_STDERR

#include <assert.h>

void setup() {                
    // initialize serial communication at 9600 bits per second.
    Serial.begin(115200);  
    Serial.println();
    Serial.println(F("hello"));
    delay(10);
    assert(false);
    Serial.println(F("this should not appear"));
}

void loop(){
}

void __assert(const char *__func, const char *__file, int __lineno, const char *__sexp) {
    Serial.println(F("----- assert information -----"));
    Serial.println(__func);
    Serial.println(__file);
    Serial.println(__lineno, DEC);
    Serial.println(__sexp);
    Serial.flush();
    delay(100);
    abort();
}

This aborts correctly (i.e. this should not appear is not printed), but I do not get any of the assert informations as described in __assert.

  • any idea how to / is it possible to get this to work already now?
  • if not, is it something you can make possible? :) .
@ghost ghost added this to the v2.1.0 milestone Mar 2, 2021
@Wenn0101
Copy link
Contributor

MBED_ASSERT() is available and will print the information you are looking for plus a bit of extra OS level information.
I looked into creating an assert() shell function for this, but it felt a bit like I was just creating unnecessary confusion since the MBED_ASSERT function is available.
I can't find much online about people using assert with arduino, and I don't think it is considered part of the standard API, so I think I will close this as is. Let me know if you think it deserves a re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants