This repository has been archived by the owner on Jan 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
[wip] xpcc error model using assertions #185
Merged
salkinium
merged 8 commits into
roboterclubaachen:develop
from
salkinium:feature/xpcc_assertion_handlers
Nov 16, 2016
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
817d6ce
[boards] Add AL-AVREB_CAN board.
salkinium f7c26cb
[architecture] Add assertion handler interface.
salkinium ca611b6
[cortex] Add assertion handler implementation.
salkinium bae528f
[hosted] Add assertion handler implementation.
salkinium c56375a
[avr] Add assertion handler implementation.
salkinium 736dcd0
[examples] Add Cortex-M assertion example.
salkinium ac92fbc
[examples] Add Linux assertion example.
salkinium 50bc064
[examples] Add AVR assertion example.
salkinium File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# path to the xpcc root directory | ||
xpccpath = '../../..' | ||
# execute the common SConstruct file | ||
execfile(xpccpath + '/scons/SConstruct') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// coding: utf-8 | ||
/* Copyright (c) 2016, Roboterclub Aachen e.V. | ||
* All Rights Reserved. | ||
* | ||
* The file is part of the xpcc library and is released under the 3-clause BSD | ||
* license. See the file `LICENSE` for the full license governing this code. | ||
*/ | ||
// ---------------------------------------------------------------------------- | ||
|
||
#include <xpcc/architecture/platform.hpp> | ||
#include <avr/pgmspace.h> | ||
|
||
using xpcc::accessor::asFlash; | ||
|
||
// Flash support on avr-gcc is so horribly broken. | ||
#define IFS(s) asFlash(PSTR(s)) | ||
|
||
#define XPCC_CAN_MODULE_NAME "can" | ||
#define XPCC_IOBUFFER_MODULE_NAME "iobuffer" | ||
#define XPCC_UART_MODULE_NAME "uart" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are supposed to be declared by the module, perhaps overwriteable? |
||
|
||
extern "C" void | ||
xpcc_abandon(const char * module, | ||
const char * location, | ||
const char * failure) | ||
{ | ||
serialStream << IFS("Assertion '") | ||
<< asFlash(module) << '.' | ||
<< asFlash(location) << '.' | ||
<< asFlash(failure) | ||
<< IFS("' failed! Abandoning.") << xpcc::endl; | ||
|
||
Leds::setOutput(); | ||
while(1) { | ||
Leds::write(1); | ||
xpcc::delayMilliseconds(20); | ||
Leds::write(0); | ||
xpcc::delayMilliseconds(180); | ||
} | ||
} | ||
|
||
static xpcc::Abandonment | ||
test_assertion_handler(const char * module, | ||
const char * /* location */, | ||
const char * /* failure */) | ||
{ | ||
serialStream << IFS("#1: '") << asFlash(module) << IFS("'!") << xpcc::endl; | ||
// The strings are located in FLASH!!! | ||
if (strcmp_P(module, PSTR(XPCC_IOBUFFER_MODULE_NAME)) == 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit sucky, if your application should be portable between AVR and Cortex-M. But I see not other way than to place the strings into Flash, since this feature is supposed to be used on ATtinys too. |
||
return xpcc::Abandonment::Ignore; | ||
return xpcc::Abandonment::DontCare; | ||
} | ||
XPCC_ASSERTION_HANDLER(test_assertion_handler); | ||
|
||
static xpcc::Abandonment | ||
test_assertion_handler2(const char * /* module */, | ||
const char * location, | ||
const char * /* failure */) | ||
{ | ||
serialStream << IFS("#2: '") << asFlash(location) << IFS("'!") << xpcc::endl; | ||
return xpcc::Abandonment::DontCare; | ||
} | ||
XPCC_ASSERTION_HANDLER(test_assertion_handler2); | ||
|
||
static xpcc::Abandonment | ||
test_assertion_handler3(const char * /* module */, | ||
const char * /* location */, | ||
const char * failure) | ||
{ | ||
serialStream << IFS("#3: '") << asFlash(failure) << IFS("'!") << xpcc::endl; | ||
return xpcc::Abandonment::DontCare; | ||
} | ||
XPCC_ASSERTION_HANDLER(test_assertion_handler3); | ||
|
||
// ---------------------------------------------------------------------------- | ||
int main() | ||
{ | ||
Board::initialize(); | ||
Leds::setOutput(); | ||
|
||
xpcc_assert(true, XPCC_CAN_MODULE_NAME, "init", "timeout"); | ||
|
||
xpcc_assert_debug(false, XPCC_IOBUFFER_MODULE_NAME, "tx", "full"); | ||
|
||
xpcc_assert(false, XPCC_UART_MODULE_NAME, "init", "mode"); | ||
|
||
while (1) | ||
{ | ||
Led3::toggle(); | ||
xpcc::delayMilliseconds(500); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build] | ||
board = al_avreb_can | ||
buildpath = ${xpccpath}/build/avr/${name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# path to the xpcc root directory | ||
xpccpath = '../../..' | ||
# execute the common SConstruct file | ||
execfile(xpccpath + '/scons/SConstruct') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <xpcc/architecture/platform.hpp> | ||
|
||
#define XPCC_CAN_MODULE_NAME "can" | ||
#define XPCC_IOBUFFER_MODULE_NAME "iobuffer" | ||
#define XPCC_UART_MODULE_NAME "uart" | ||
|
||
static xpcc::Abandonment | ||
test_assertion_handler(const char * module, | ||
const char * location, | ||
const char * failure) | ||
{ | ||
if (strcmp(module, XPCC_IOBUFFER_MODULE_NAME) == 0) | ||
return xpcc::Abandonment::Ignore; | ||
return xpcc::Abandonment::DontCare; | ||
} | ||
XPCC_ASSERTION_HANDLER(test_assertion_handler); | ||
|
||
// ---------------------------------------------------------------------------- | ||
int | ||
main() | ||
{ | ||
xpcc_assert(true, XPCC_CAN_MODULE_NAME, "init", "timeout"); | ||
|
||
xpcc_assert_debug(false, XPCC_IOBUFFER_MODULE_NAME, "tx", "full"); | ||
|
||
xpcc_assert(false, XPCC_UART_MODULE_NAME, "init", "mode"); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build] | ||
device = hosted | ||
buildpath = ${xpccpath}/build/linux/${name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# path to the xpcc root directory | ||
xpccpath = '../../..' | ||
# execute the common SConstruct file | ||
execfile(xpccpath + '/scons/SConstruct') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <xpcc/architecture/platform.hpp> | ||
|
||
#define XPCC_CAN_MODULE_NAME "can" | ||
#define XPCC_IOBUFFER_MODULE_NAME "iobuffer" | ||
#define XPCC_UART_MODULE_NAME "uart" | ||
|
||
using namespace Board; | ||
|
||
extern "C" void xpcc_abandon(const char * module, | ||
const char * location, | ||
const char * failure) | ||
{ | ||
XPCC_LOG_ERROR << "Assertion '" | ||
<< module << "." << location << "." << failure | ||
<< "' failed! Abandoning." << xpcc::endl; | ||
|
||
LedGreen::setOutput(); | ||
while(1) { | ||
LedBlue::set(); | ||
xpcc::delayMilliseconds(20); | ||
LedBlue::reset(); | ||
xpcc::delayMilliseconds(180); | ||
} | ||
} | ||
|
||
static xpcc::Abandonment | ||
test_assertion_handler(const char * module, | ||
const char * /* location */, | ||
const char * /* failure */) | ||
{ | ||
if (strcmp(module, XPCC_IOBUFFER_MODULE_NAME) == 0) | ||
return xpcc::Abandonment::Ignore; | ||
return xpcc::Abandonment::DontCare; | ||
} | ||
XPCC_ASSERTION_HANDLER(test_assertion_handler); | ||
|
||
// ---------------------------------------------------------------------------- | ||
int | ||
main() | ||
{ | ||
Board::initialize(); | ||
|
||
xpcc_assert(true, XPCC_CAN_MODULE_NAME, "init", "timeout"); | ||
|
||
xpcc_assert_debug(false, XPCC_IOBUFFER_MODULE_NAME, "tx", "full"); | ||
|
||
xpcc_assert(false, XPCC_UART_MODULE_NAME, "init", "mode"); | ||
|
||
while(1) | ||
{ | ||
LedRed::toggle(); | ||
xpcc::delayMilliseconds(500); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build] | ||
board = stm32f469_discovery | ||
buildpath = ${xpccpath}/build/stm32f469_discovery/${name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AVR is pretty cool, but this Flash f-up is pretty unforgiveable. This should be solved at a compiler level, not a user application level though.