mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 07:13:34 +08:00
l3gd20: added testerror command
useful for testing error handling
This commit is contained in:
@@ -204,6 +204,9 @@ public:
|
|||||||
// print register dump
|
// print register dump
|
||||||
void print_registers();
|
void print_registers();
|
||||||
|
|
||||||
|
// trigger an error
|
||||||
|
void test_error();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int probe();
|
virtual int probe();
|
||||||
|
|
||||||
@@ -1098,6 +1101,13 @@ L3GD20::print_registers()
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
L3GD20::test_error()
|
||||||
|
{
|
||||||
|
// trigger a deliberate error
|
||||||
|
write_reg(ADDR_CTRL_REG3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
L3GD20::self_test()
|
L3GD20::self_test()
|
||||||
{
|
{
|
||||||
@@ -1287,10 +1297,25 @@ regdump(void)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* trigger an error
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
test_error(void)
|
||||||
|
{
|
||||||
|
if (g_dev == nullptr)
|
||||||
|
errx(1, "driver not running");
|
||||||
|
|
||||||
|
printf("regdump @ %p\n", g_dev);
|
||||||
|
g_dev->test_error();
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
warnx("missing command: try 'start', 'info', 'test', 'reset' or 'regdump'");
|
warnx("missing command: try 'start', 'info', 'test', 'reset', 'testerror' or 'regdump'");
|
||||||
warnx("options:");
|
warnx("options:");
|
||||||
warnx(" -X (external bus)");
|
warnx(" -X (external bus)");
|
||||||
warnx(" -R rotation");
|
warnx(" -R rotation");
|
||||||
@@ -1353,5 +1378,11 @@ l3gd20_main(int argc, char *argv[])
|
|||||||
if (!strcmp(verb, "regdump"))
|
if (!strcmp(verb, "regdump"))
|
||||||
l3gd20::regdump();
|
l3gd20::regdump();
|
||||||
|
|
||||||
errx(1, "unrecognized command, try 'start', 'test', 'reset', 'info' or 'regdump'");
|
/*
|
||||||
|
* trigger an error
|
||||||
|
*/
|
||||||
|
if (!strcmp(verb, "testerror"))
|
||||||
|
l3gd20::test_error();
|
||||||
|
|
||||||
|
errx(1, "unrecognized command, try 'start', 'test', 'reset', 'info', 'testerror' or 'regdump'");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user