[riot-notifications] [RIOT-OS/RIOT] tests: periph_pm: add peripheral test. (#8848)

Alexandre Abadie notifications at github.com
Thu Apr 5 09:17:52 CEST 2018


aabadie requested changes on this pull request.

Played a bit with the test application and I have other comments.
I think it works but the commands messages (in case of usage errors) could be improved. I'm proposing a refactoring of parse_mode and parse_duration function.

> +#include <stdio.h>
+#include <stdlib.h>
+
+#include "periph/pm.h"
+#ifdef MODULE_PM_LAYERED
+#ifdef MODULE_PERIPH_RTC
+#include "periph/rtc.h"
+#endif
+#include "pm_layered.h"
+#endif
+#include "shell.h"
+
+#ifdef MODULE_PM_LAYERED
+static int parse_mode(int argc, char **argv)
+{
+    if (argc < 2) {

This should be moved to each command function handler and if a wrong number of arguments is given, the command prints a usage message `Usage: unblock <power mode>` or `Usage: unblock_rtc <power mode> <duration>`.
Otherwise the error message doesn't give any hint on how to correctly use the command. Maybe introduce a `_check_usage(int argc, int expected_argc)` function for this ?

Then the parse_mode and parse_duration could be simplified with this signature:
```c
static int _parse_mode(const char * mode)
static int _parse_duration(const char * duration)
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/8848#pullrequestreview-109597715
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20180405/89aa6025/attachment.html>


More information about the notifications mailing list