diff options
author | Andrew Tridgell <andrew@tridgell.net> | 2015-01-01 08:44:50 +1100 |
---|---|---|
committer | Andrew Tridgell <andrew@tridgell.net> | 2015-01-01 08:51:44 +1100 |
commit | 2ac3a6fcf4ab051b53f635d696a45edac438228e (patch) | |
tree | 89ed06bee118382cbec10974c9ac3209f5f5b485 /src/drivers/lsm303d | |
parent | 5c1da70d0c738c0614ea1652a510f126c31369d8 (diff) | |
download | px4-firmware-2ac3a6fcf4ab051b53f635d696a45edac438228e.tar.gz px4-firmware-2ac3a6fcf4ab051b53f635d696a45edac438228e.tar.bz2 px4-firmware-2ac3a6fcf4ab051b53f635d696a45edac438228e.zip |
l3m303d: added testerror command
useful for testing error handling
Diffstat (limited to 'src/drivers/lsm303d')
-rw-r--r-- | src/drivers/lsm303d/lsm303d.cpp | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/drivers/lsm303d/lsm303d.cpp b/src/drivers/lsm303d/lsm303d.cpp index dbd5c1f4c..a062b2828 100644 --- a/src/drivers/lsm303d/lsm303d.cpp +++ b/src/drivers/lsm303d/lsm303d.cpp @@ -237,6 +237,11 @@ public: */ void print_registers(); + /** + * deliberately trigger an error + */ + void test_error(); + protected: virtual int probe(); @@ -1690,6 +1695,13 @@ LSM303D::print_registers() } } +void +LSM303D::test_error() +{ + // trigger an error + write_reg(ADDR_CTRL_REG3, 0); +} + LSM303D_mag::LSM303D_mag(LSM303D *parent) : CDev("LSM303D_mag", LSM303D_DEVICE_PATH_MAG), _parent(parent), @@ -1969,10 +1981,24 @@ regdump() exit(0); } +/** + * trigger an error + */ +void +test_error() +{ + if (g_dev == nullptr) + errx(1, "driver not running\n"); + + g_dev->test_error(); + + exit(0); +} + void usage() { - warnx("missing command: try 'start', 'info', 'test', 'reset', 'regdump'"); + warnx("missing command: try 'start', 'info', 'test', 'reset', 'testerror' or 'regdump'"); warnx("options:"); warnx(" -X (external bus)"); warnx(" -R rotation"); @@ -2035,5 +2061,11 @@ lsm303d_main(int argc, char *argv[]) if (!strcmp(verb, "regdump")) lsm303d::regdump(); - errx(1, "unrecognized command, try 'start', 'test', 'reset', 'info', or 'regdump'"); + /* + * trigger an error + */ + if (!strcmp(verb, "testerror")) + lsm303d::test_error(); + + errx(1, "unrecognized command, try 'start', 'test', 'reset', 'info', 'testerror' or 'regdump'"); } |