Archive 07/10/2020.

TP4 : Extending a RIOT application

flagoutt

Bonjour,
Lorsque je lance le flash, j’ai des erreurs :
Building application “basic-shell” for “iotlab-m3” with MCU “stm32f1”.

/home/jovyan/work/iot-lab-training/riot/basics/shell/main.c:33:1: error: expected ‘,’ or ‘;’ before ‘int’
int main(void);
^~~
/home/jovyan/work/iot-lab-training/riot/basics/shell/main.c:34:1: error: expected identifier or ‘(’ before ‘{’ token
{
^
/home/jovyan/work/iot-lab-training/riot/basics/shell/main.c:28:30: error: ‘shell_commands’ defined but not used [-Werror=unused-const-variable=]
static const shell_command_t shell_commands[] = {
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
/home/jovyan/work/iot-lab-training/riot/RIOT/Makefile.base:109: recipe for target ‘/home/jovyan/work/iot-lab-training/riot/basics/shell/bin/iotlab-m3/application_basic-shell/main.o’ failed
make[1]: *** [/home/jovyan/work/iot-lab-training/riot/basics/shell/bin/iotlab-m3/application_basic-shell/main.o] Error 1
/home/jovyan/work/iot-lab-training/riot/basics/shell/…/…/RIOT/Makefile.include:540: recipe for target ‘/home/jovyan/work/iot-lab-training/riot/basics/shell/bin/iotlab-m3/application_basic-shell.a’ failed
make: *** [/home/jovyan/work/iot-lab-training/riot/basics/shell/bin/iotlab-m3/application_basic-shell.a] Error 2

Je pense avoir mis au bon endroit les commandes dans les 2 fichiers main.c et makefile, je ne comprends pas.

Fichier main.c
#include <stdio.h>

/* Include the shell header /
#include “shell.h”
/
Implement the shell function callback here */
static int _board_handler(int argc, char *argv)
{
/
These parameters are not used, avoid a warning during build */
(void)argc;
(void)argv;

puts(RIOT_BOARD);

return 0;

}

static int _cpu_handler(int argc, char *argv)
{
/
These parameters are not used, avoid a warning during build */
(void)argc;
(void)argv;

puts(RIOT_CPU);

return 0;

}
/* Add the shell command to the list of commands here /
static const shell_command_t shell_commands[] = {
{ “board”, “Print the board name”, _board_handler },
{ “cpu”, “Print the cpu name”, _cpu_handler },
{ NULL, NULL, NULL }
}
int main(void);
{
/
Start the shell here */
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
return 0;
}

Fichier makefile
APPLICATION ?= basic-shell

BOARD ?= native

Add module for the shell here

USEMODULE += shell

RIOTBASE ?= $(CURDIR)/…/…/RIOT

include $(RIOTBASE)/Makefile.include

Merci de votre aide

aabadie2

Bonjour,

Comme le dit le compilateur, il y a une erreur de syntaxe (en fait 2) dans votre code:

  • Il faut rajouter un ; à la fin de la ligne juste avant int main(), c’est-à-dire après }.
  • Il ne faut pas mettre de ; à la fin de la ligne int main().