Addo
April 9, 2019, 1:05pm
1
If you are asking a question, please follow this template:
to move stepper motor forward and backward
#include <stdio.h>
#include “mgos_gpio.h”
#define dirpin 4
#define steppin 3
enum mgos_app_init_result mgos_app_init(void) {
mgos_gpio_set_mode(dirpin, MGOS_GPIO_MODE_OUTPUT);
mgos_gpio_write (dirpin, 1);
for(int x = 0; x < 200; x++) {
mgos_gpio_set_mode(steppin, MGOS_GPIO_MODE_OUTPUT);
mgos_gpio_write (steppin, 1);
mgos_gpio_write (steppin, 0);
}
mgos_gpio_set_mode(dirpin, MGOS_GPIO_MODE_OUTPUT);
mgos_gpio_write (dirpin, 0);
for(int x = 0; x < 400; x++) {
mgos_gpio_set_mode(steppin, MGOS_GPIO_MODE_OUTPUT);
mgos_gpio_write (steppin, 1);
mgos_gpio_write (steppin, 0);
}
return MGOS_APP_INIT_SUCCESS;
}
3. i cant mos build this code, it alwasy failed. there was no error in my code but it cant build.
whats wrong with my code, please help me. i am still new with mongoose os
nliviu
April 9, 2019, 1:28pm
2
You have a file ._main.c
in the src
folder which is not a valid c file.
Addo
April 9, 2019, 1:33pm
3
oh ok, so what do i do?
do i need to make a new c file to put my code?
nliviu
April 9, 2019, 2:01pm
4
main.c
and ._main.c
are different files. Notice the before main.c.
Run dir src
in the application’s directory and show the output.
Ex:
C:\error>dir src
Volume in drive C is xxx
Volume Serial Number is yyy
Directory of C:\error\src
09.04.2019 17:00 <DIR> .
09.04.2019 17:00 <DIR> ..
09.04.2019 17:00 0 ._main.c
09.04.2019 16:57 0 main.c
Addo
April 9, 2019, 2:13pm
5
04/09/2019 08:35 PM .
04/09/2019 08:35 PM …
04/09/2019 08:35 PM 2,191 main.c
1 File(s) 2,191 bytes
why there is no ._main.c in my src directory?
Addo
April 9, 2019, 2:19pm
7
04/05/2019 09:29 AM 6,148 .DS_Store
04/05/2019 10:22 AM 4,096 ._.DS_Store
04/05/2019 10:22 AM 4,096 ._main.c
3 File(s) 14,340 bytes
nliviu
April 9, 2019, 2:20pm
8
Files from a mac
Delete all the dot files.
Addo
April 9, 2019, 2:42pm
9
so i delete this all?
04/05/2019 09:29 AM 6,148 .DS_Store
04/05/2019 10:22 AM 4,096 ._.DS_Store
04/05/2019 10:22 AM 4,096 ._main.c
Addo
April 9, 2019, 2:46pm
10
ok i already delete all the dot files.but i still failed to build
nliviu
April 9, 2019, 2:57pm
11
Can’t help without the build log.
Addo
April 9, 2019, 4:52pm
12
enum mgos_app_init_result mgos_app_init(void) { << undeclared , return error with value
what is that mean?
nliviu
April 9, 2019, 5:16pm
13
You have several C language errors which are not related to Mongoose OS:
error: return type is an incomplete type in line 57
‘MGOS_APP_INIT_SUCCESS’ undeclared
That means that the header files defining them are not included in main.c
Add
#include "mgos.h"
at the top of your file and rebuild.
Addo
April 9, 2019, 5:22pm
14
oh my god, thanks sir
its finally can be builded , but im not yet test it with my stepper motor
but still thank you very much sir, have a nice day