Commit f68967734b7078a18713f11ec9f134b7e19d3060
1 parent
d6e16d2e
Prise en charge des "démo étapes"
Showing
3 changed files
with
37 additions
and
26 deletions
Show diff stats
Makefile
@@ -3,9 +3,11 @@ OBJ = obj | @@ -3,9 +3,11 @@ OBJ = obj | ||
3 | SRC = src | 3 | SRC = src |
4 | INCLUDE = include | 4 | INCLUDE = include |
5 | CFLAGS = | 5 | CFLAGS = |
6 | -CLIBS = -lusb-1.0 | 6 | +CLIBS = -lusb-1.0 -I"C:\Program Files\zLib\libusb-1.0.23\include" -B"C:\Program Files\zLib\libusb-1.0.23\MinGW32\static" |
7 | GNUMAKEFLAGS = --no-print-directory | 7 | GNUMAKEFLAGS = --no-print-directory |
8 | 8 | ||
9 | +gcc = gcc | ||
10 | +gcc := "/mnt/c/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe" | ||
9 | 11 | ||
10 | 12 | ||
11 | VERBOSE_THRESHOLD?=3 | 13 | VERBOSE_THRESHOLD?=3 |
@@ -20,30 +22,23 @@ endif | @@ -20,30 +22,23 @@ endif | ||
20 | 22 | ||
21 | 23 | ||
22 | 24 | ||
23 | -all : main demostep | 25 | +all : main |
24 | 26 | ||
25 | 27 | ||
28 | +version : | ||
29 | + ${gcc} -v | ||
26 | 30 | ||
27 | main : libusb_wrapper ${SRC}/main.c | 31 | main : libusb_wrapper ${SRC}/main.c |
28 | - gcc -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} | ||
29 | - gcc -o ${BIN}/$@.out ${OBJ}/main.o ${OBJ}/libusb_wrapper.o ${CFLAGS} ${CLIBS} | ||
30 | - | ||
31 | -demostep : STEP4.1 | ||
32 | - | ||
33 | -STEP4.1 : ${SRC}/GetUsbInfos.c bin | ||
34 | - gcc -o ${BIN}/STEP4.1.out ${SRC}/GetUsbInfos.c ${CLIBS} ${CFLAGS} | ||
35 | - | ||
36 | -STEP4.2 : ${SRC}/FourPointTwo.c bin | ||
37 | - gcc -o ${BIN}/STEP4.2.out ${SRC}/FourPointTwo.c ${CLIBS} ${CFLAGS} | ||
38 | - | ||
39 | -STEP4.3 : ${SRC}/FourPointThree.c bin | ||
40 | - gcc -o ${BIN}/STEP4.3.out ${SRC}/FourPointThree.c ${CLIBS} ${CFLAGS} | 32 | + ${gcc} -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} |
33 | + ${gcc} -o ${BIN}/$@.exe ${OBJ}/main.o ${OBJ}/libusb_wrapper.o ${CFLAGS} ${CLIBS} | ||
41 | 34 | ||
35 | +demostep : main | ||
36 | + ${BIN}/main.exe demo4.1 | ||
42 | 37 | ||
43 | libs: libusb_wrapper | 38 | libs: libusb_wrapper |
44 | 39 | ||
45 | libusb_wrapper: obj ${SRC}/libusb_wrapper.c ${INCLUDE}/libusb_wrapper.h | 40 | libusb_wrapper: obj ${SRC}/libusb_wrapper.c ${INCLUDE}/libusb_wrapper.h |
46 | - gcc -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} | 41 | + ${gcc} -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} |
47 | 42 | ||
48 | 43 | ||
49 | 44 |
README.md
@@ -13,7 +13,7 @@ Pour compiler il faut lancer la commande `make` | @@ -13,7 +13,7 @@ Pour compiler il faut lancer la commande `make` | ||
13 | 13 | ||
14 | ## Utiliser | 14 | ## Utiliser |
15 | 15 | ||
16 | -Pour lancer les programmes ... | 16 | +Pour lancer le programme principale, il faut exécuter bin/main.exe |
17 | 17 | ||
18 | -Demo des questions se lancent en faisant : ... | 18 | +Les demo des questions se lancent avec `make demostep` (pour l'instant) |
19 | 19 |
src/main.c
1 | #include "libusb_wrapper.h" | 1 | #include "libusb_wrapper.h" |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | 3 | ||
4 | -int main(){ | 4 | +int main(int argc, char *argv[]){ |
5 | printf("Hello World :-|\n"); | 5 | printf("Hello World :-|\n"); |
6 | 6 | ||
7 | libusb_context *context; | 7 | libusb_context *context; |
8 | - usbinit(&context); | 8 | + usbinit(&context); |
9 | 9 | ||
10 | - //if 4.1 | ||
11 | - displayDevices(context); | ||
12 | - //else | 10 | + if(argc>1){ |
11 | + //command mode | ||
12 | + if(strcmp(argv[1], "demo4.1") == 0) { //if 4.1 | ||
13 | + printf("\e[91mDemo 4.1\e[39m\n"); | ||
14 | + displayDevices(context); | ||
15 | + } | ||
16 | + else if(strcmp(argv[1], "demo4.2") == 0){//if 4.2 | ||
17 | + printf("\e[91mDemo 4.2\e[39m\n"); | ||
18 | + //displayDeviceEndpoints(Ourdevice); | ||
19 | + //else | ||
20 | + }else{ | ||
21 | + printf("Wrong command\n"); | ||
22 | + } | ||
23 | + | ||
24 | + }else{ | ||
25 | + //interactive mode | ||
26 | + printf("Welcome to interactive mode\n"); | ||
27 | + | ||
28 | + /*Future code*/ | ||
29 | + | ||
30 | + printf("Finished\n"); | ||
31 | + } | ||
13 | 32 | ||
14 | - //if 4.2 | ||
15 | - //displayDeviceEndpoints(Ourdevice); | ||
16 | - //else | ||
17 | 33 | ||
18 | usbclose(context); | 34 | usbclose(context); |
19 | 35 |