From: Justin Mitchell Date: Tue, 5 Nov 2013 10:08:51 +0000 (+0000) Subject: Fix the windows compile mode to be a console app X-Git-Url: http://stoneship.org.uk/projects/git/?a=commitdiff_plain;h=45c9618a00a07307660ab7721e7ebcfa78da740c;p=bootloader Fix the windows compile mode to be a console app --- diff --git a/cli/Makefile b/cli/Makefile index 3bf6538..415fa07 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -3,12 +3,12 @@ LDFLAGS= $(CFLAGS) SRC=log.c boot.c protocol.c devices.c memory.c -WINDOWS=0 +WINDOWS=1 ifeq ($(WINDOWS),1) PREFIX=i686-w64-mingw32- SRC += serial-win.c -CFLAGS += -static -mwindows +CFLAGS += -static #-mwindows else CFLAGS += -fPIC -static #-m32 SRC += serial.c diff --git a/cli/boot.c b/cli/boot.c index 8a522ab..e243d3b 100644 --- a/cli/boot.c +++ b/cli/boot.c @@ -19,17 +19,6 @@ #define PORT_NAME "/dev/ttyUSB0" #endif -#ifdef _WIN32 -static void keypress(void) -{ - printf("Press ENTER to exit\n"); - getchar(); -} -#else -static void keypress(void) {} -#endif - - void usage(const char * name) { loge("Usage: %s [-b baud] [-p port] [-i] [-v] {file.hex}\n", name); @@ -185,7 +174,6 @@ int main(int argc, char **argv) if (!idonly && optind >= argc) { loge("Error: missing hexfile"); - keypress(); return 1; } @@ -195,7 +183,6 @@ int main(int argc, char **argv) FILE * fd = NULL; if ((fd = fopen(argv[optind], "r"))==NULL) { loge("Error opening %s: %s", argv[optind], strerror(errno)); - keypress(); return 1; } ram = load_ihex(fd); @@ -208,14 +195,12 @@ int main(int argc, char **argv) logd("open serial port %s at %d baud", port, baud); port_t * pt = serial_open(port, baud); if (pt == NULL) { - keypress(); return 1; } uint16_t maxmem; uint16_t devid; if (loader_connect(pt, &maxmem, &devid)) { - keypress(); return 1; } @@ -229,7 +214,6 @@ int main(int argc, char **argv) logi(" Max Mem: %d", dev->memsize ); } - keypress(); return 0; } if (dev) logd("Device Name: %s", dev->name); @@ -237,7 +221,6 @@ int main(int argc, char **argv) /* check that the selected program will fit on this device */ if (makesafe_mem(&ram, maxmem)) { serial_close(pt); - keypress(); return 1; } logd("After re-organisation"); @@ -254,7 +237,6 @@ int main(int argc, char **argv) /* finished */ serial_close(pt); logd("done."); - keypress(); return 0; } diff --git a/cli/log.c b/cli/log.c index e32cd67..be6380e 100644 --- a/cli/log.c +++ b/cli/log.c @@ -18,10 +18,12 @@ void logit(int type, const char * format, ...) { static int hConHandle = 0; - if (hConHandle == 0) { + if (0 && hConHandle == 0) { CONSOLE_SCREEN_BUFFER_INFO coninfo; AllocConsole(); - //AttachConsole(ATTACH_PARENT_PROCESS); + if (AttachConsole(ATTACH_PARENT_PROCESS) == ERROR_INVALID_HANDLE) { + AllocConsole(); + } GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); coninfo.dwSize.Y = MAX_CONSOLE_LINES; SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);