From f68967734b7078a18713f11ec9f134b7e19d3060 Mon Sep 17 00:00:00 2001 From: Axel CHEMIN Date: Thu, 19 Nov 2020 14:46:22 +0100 Subject: [PATCH] Prise en charge des "démo étapes" --- Makefile | 27 +++++++++++---------------- README.md | 4 ++-- src/main.c | 32 ++++++++++++++++++++++++-------- 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index a935378..386ae4c 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,11 @@ OBJ = obj SRC = src INCLUDE = include CFLAGS = -CLIBS = -lusb-1.0 +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" GNUMAKEFLAGS = --no-print-directory +gcc = gcc +gcc := "/mnt/c/Program Files (x86)/mingw-w64/i686-8.1.0-posix-dwarf-rt_v6-rev0/mingw32/bin/gcc.exe" VERBOSE_THRESHOLD?=3 @@ -20,30 +22,23 @@ endif -all : main demostep +all : main +version : + ${gcc} -v main : libusb_wrapper ${SRC}/main.c - gcc -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} - gcc -o ${BIN}/$@.out ${OBJ}/main.o ${OBJ}/libusb_wrapper.o ${CFLAGS} ${CLIBS} - -demostep : STEP4.1 - -STEP4.1 : ${SRC}/GetUsbInfos.c bin - gcc -o ${BIN}/STEP4.1.out ${SRC}/GetUsbInfos.c ${CLIBS} ${CFLAGS} - -STEP4.2 : ${SRC}/FourPointTwo.c bin - gcc -o ${BIN}/STEP4.2.out ${SRC}/FourPointTwo.c ${CLIBS} ${CFLAGS} - -STEP4.3 : ${SRC}/FourPointThree.c bin - gcc -o ${BIN}/STEP4.3.out ${SRC}/FourPointThree.c ${CLIBS} ${CFLAGS} + ${gcc} -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} + ${gcc} -o ${BIN}/$@.exe ${OBJ}/main.o ${OBJ}/libusb_wrapper.o ${CFLAGS} ${CLIBS} +demostep : main + ${BIN}/main.exe demo4.1 libs: libusb_wrapper libusb_wrapper: obj ${SRC}/libusb_wrapper.c ${INCLUDE}/libusb_wrapper.h - gcc -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} + ${gcc} -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS} diff --git a/README.md b/README.md index 85ce20e..87a835a 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Pour compiler il faut lancer la commande `make` ## Utiliser -Pour lancer les programmes ... +Pour lancer le programme principale, il faut exécuter bin/main.exe -Demo des questions se lancent en faisant : ... +Les demo des questions se lancent avec `make demostep` (pour l'instant) diff --git a/src/main.c b/src/main.c index 63a3dcc..c3a85a2 100644 --- a/src/main.c +++ b/src/main.c @@ -1,19 +1,35 @@ #include "libusb_wrapper.h" #include -int main(){ +int main(int argc, char *argv[]){ printf("Hello World :-|\n"); libusb_context *context; - usbinit(&context); + usbinit(&context); - //if 4.1 - displayDevices(context); - //else + if(argc>1){ + //command mode + if(strcmp(argv[1], "demo4.1") == 0) { //if 4.1 + printf("\e[91mDemo 4.1\e[39m\n"); + displayDevices(context); + } + else if(strcmp(argv[1], "demo4.2") == 0){//if 4.2 + printf("\e[91mDemo 4.2\e[39m\n"); + //displayDeviceEndpoints(Ourdevice); + //else + }else{ + printf("Wrong command\n"); + } + + }else{ + //interactive mode + printf("Welcome to interactive mode\n"); + + /*Future code*/ + + printf("Finished\n"); + } - //if 4.2 - //displayDeviceEndpoints(Ourdevice); - //else usbclose(context); -- libgit2 0.21.2