@@ -127,6 +127,9 @@ void autoCalibrate() {
127127
128128
129129void print () {
130+ // firmware version
131+ std::cout << powerSensor->getVersion () << std::endl;
132+
130133 PowerSensor3::State startState, stopState;
131134
132135 measureSensors (&startState, &stopState);
@@ -173,7 +176,7 @@ void print() {
173176
174177void usage (char *argv[]) {
175178 std::cerr << " usage: " << argv[0 ] << " [-h] [-d device] [-s sensor] [-t type] "
176- " [-m name] [-a | -v volt] [-n sensitivity] [-x polarity] [-o on/off] [-p]" << std::endl;
179+ " [-m name] [-a | -v volt] [-n sensitivity] [-x polarity] [-o on/off] [-p] [-r] [-f] " << std::endl;
177180 std::cerr << " -h prints this help" << std::endl;
178181 std::cerr << " -d selects the device (default: /dev/ttyACM0)" << std::endl;
179182 std::cerr << " -s selects the sensor (0-" << PowerSensor3::MAX_SENSORS << " )" << std::endl;
@@ -189,6 +192,8 @@ void usage(char *argv[]) {
189192 std::cerr << " -x sets the polarity of a sensor. 1 for normal, -1 for inverted" << std::endl;
190193 std::cerr << " -o turns a sensor on (1) or off (0)" << std::endl;
191194 std::cerr << " -p prints configured values" << std::endl;
195+ std::cerr << " -r reboots the device" << std::endl;
196+ std::cerr << " -f reboots the device to DFU mode" << std::endl;
192197 std::cerr << " example: " << argv[0 ] << " -d /dev/ttyACM0 -s 0 -t MLX10 -v 1.65 "
193198 " -o 1 -s 1 -t voltage0 -v 0 -n 0.95 -o 1 -p" << std::endl;
194199 std::cerr << " Known current sensor types: MLX10, MLX20, MLX50, MLX75." << std::endl;
@@ -202,7 +207,7 @@ int main(int argc, char *argv[]) {
202207 bool doPrint = false ;
203208
204209 std::cout << " psconfig version " << PowerSensor3::POWERSENSOR_VERSION << std::endl << std::endl;
205- for (int opt; (opt = getopt (argc, argv, " d:s:i:t:m:av:n:x:o:ph " )) >= 0 ;) {
210+ for (int opt; (opt = getopt (argc, argv, " d:s:i:t:m:av:n:x:o:phrf " )) >= 0 ;) {
206211 switch (opt) {
207212 // device select
208213 case ' d' :
@@ -271,6 +276,18 @@ int main(int argc, char *argv[]) {
271276 doPrint = true ;
272277 break ;
273278
279+ // reboot device
280+ case ' r' :
281+ std::cout << " Rebooting device, ignorning any config changes" << std::endl;
282+ getPowerSensor (device)->reset (false );
283+ exit (0 ); // disconnect after a reset
284+
285+ // reboot device to DFU mode
286+ case ' f' :
287+ std::cout << " Rebooting device to DFU mode, ignoring any config changes" << std::endl;
288+ getPowerSensor (device)->reset (true );
289+ return 0 ; // disconnect after a reset
290+
274291 // help
275292 case ' h' :
276293 usage (argv);
0 commit comments