From: Mart Lubbers Date: Sat, 21 Jan 2017 13:39:09 +0000 (+0100) Subject: actually working code X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=64f379e7446a716257f6030157f2cb254200aa7b;p=mTask.git actually working code --- diff --git a/Makefile b/Makefile index cef4b6a..5f19a89 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ CLMLIBS:=\ BINARIES:= mTaskExamples mTaskInterpret miTask all: $(BINARIES) int/mTaskSymbols.h + make -C CleanSerial int/mTaskSymbols.h: mTaskMakeSymbols ./$< -nr > $@ diff --git a/int/.gitignore b/int/.gitignore index c63175d..db3bf7c 100644 --- a/int/.gitignore +++ b/int/.gitignore @@ -1,3 +1,4 @@ main *.o build +.dep diff --git a/int/Makefile b/int/Makefile index d0ea634..ec6ad97 100644 --- a/int/Makefile +++ b/int/Makefile @@ -201,7 +201,7 @@ CPPWARN = -Wall -Wextra -Wundef # # List all user C define here, like -D_DEBUG=1 -UDEFS = -DSTM +UDEFS = -DSTM #-DDEBUG # Define ASM defines here UADEFS = diff --git a/int/halconf.h b/int/halconf.h index 82602b4..e556d48 100644 --- a/int/halconf.h +++ b/int/halconf.h @@ -294,7 +294,7 @@ * default configuration. */ #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -#define SERIAL_DEFAULT_BITRATE 38400 +#define SERIAL_DEFAULT_BITRATE 9600 #endif /** @@ -305,7 +305,7 @@ * buffers. */ #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_BUFFERS_SIZE 16 +#define SERIAL_BUFFERS_SIZE 256 #endif /*===========================================================================*/ diff --git a/int/interface.c b/int/interface.c index 5c9b500..e94f11c 100644 --- a/int/interface.c +++ b/int/interface.c @@ -2,17 +2,16 @@ #include #include #include +#include #include "interface.h" #include "ch.h" #include "hal.h" -//char buf[1024]; - //Globals bool input_available(void) { - return qSizeX(&(&SD3)->iqueue) > 0; + return iqGetFullI(&(&SD3)->iqueue)>0; } uint8_t read_byte(void) @@ -39,8 +38,23 @@ bool read_dpin(uint8_t i) void write_apin(uint8_t i, uint8_t a) { - (void)i; - (void)a; + if(a){ + if(i == 0){ + palSetLine(LINE_LED1); + } else if(i == 1){ + palSetLine(LINE_LED2); + } else if(i == 2){ + palSetLine(LINE_LED3); + } + } else { + if(i == 0){ + palClearLine(LINE_LED1); + } else if(i == 1){ + palClearLine(LINE_LED2); + } else if(i == 2){ + palClearLine(LINE_LED3); + } + } } uint8_t read_apin(uint8_t i) @@ -65,6 +79,25 @@ void setup(void) sdStart(&SD3, NULL); } -void test(void) +void debug(char *fmt, ...) +{ + unsigned int i; + write_byte('m'); + for(i = 0; i #include +#include #ifndef STM extern int gargc; @@ -24,16 +25,8 @@ bool input_available(void); void delay(long ms); void setup(void); -void test(void); - -#ifdef STM -#define debug(s, ...) {}; -#define pdie(s) {}; -#define die(s, ...) {}; -#else -#define debug(s, ...) printf(s "\n", ##__VA_ARGS__); -#define pdie(s) {perror(s); exit(1);} -#define die(s, ...) {fprintf(stderr, s "\n", ##__VA_ARGS__); exit(1);} -#endif +void debug(char *fmt, ...); +void pdie(char *s); +void die(char *fmt, ...); #endif diff --git a/int/interface_linux.c b/int/interface_linux.c index 33fd003..1ec9347 100644 --- a/int/interface_linux.c +++ b/int/interface_linux.c @@ -144,7 +144,25 @@ void setup(void) pdie("accept"); } -void test(void) +void debug(char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +} +void pdie(char *s) +{ + perror(s); + die(""); +} + +void die(char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(EXIT_FAILURE); } diff --git a/int/interpret.c b/int/interpret.c index e124589..0a92dd0 100644 --- a/int/interpret.c +++ b/int/interpret.c @@ -7,7 +7,7 @@ #include "task.h" #include "sds.h" -#ifdef STM32F767xx +#ifdef STM #define trace(op, ...) ; #else #define trace(op, ...) ; diff --git a/int/main.c b/int/main.c index 026fd5d..3a95d0e 100644 --- a/int/main.c +++ b/int/main.c @@ -76,7 +76,7 @@ void loop(void) debug("Current task to run: %d", ct); run_task(curtask); curtask->lastrun = cyclestart; - write_byte('\n'); +// write_byte('\n'); } } @@ -88,18 +88,21 @@ int main(int argc, char *argv[]){ gargv = argv; #endif + read_byte(); //Initialize systems setup(); sds_init(); task_init(); + while(!input_available()){ + delay(100); + } debug("booting up"); while(true){ //Check for newetasks debug("loop"); loop(); - input_available(); delay(100); } return 0; diff --git a/int/sds.c b/int/sds.c index b424ff7..80c31f9 100644 --- a/int/sds.c +++ b/int/sds.c @@ -1,7 +1,7 @@ #include #include -#ifndef STM32F767xx +#ifndef STM #include #include #endif @@ -52,8 +52,6 @@ bool sds_update(void) sdss[cs].value = read16(); debug("Received sds update %d: %d", sdss[cs].id, sdss[cs].value); - printf("Received sds update %d: %d", - sdss[cs].id, sdss[cs].value); return true; } } diff --git a/int/task.c b/int/task.c index d00959a..882baa4 100644 --- a/int/task.c +++ b/int/task.c @@ -1,7 +1,7 @@ #include #include -#ifndef STM32F767xx +#ifndef STM #include #include #endif diff --git a/miTask.icl b/miTask.icl index f7c476c..d07c760 100644 --- a/miTask.icl +++ b/miTask.icl @@ -49,8 +49,8 @@ deviceSelectorSerial = accWorld getDevices mTaskTask :: (Shared ([MTaskMSGRecv],Bool,[MTaskMSGSend],Bool)) -> Task () mTaskTask ch = - deviceSelectorNetwork >>= \(p,h)->syncNetworkChannel h p "\n" decode encode ch ||- -// deviceSelectorSerial >>= \(s,set)->syncSerialChannel s set decode encode ch ||- +// deviceSelectorNetwork >>= \(p,h)->syncNetworkChannel h p "\n" decode encode ch ||- + deviceSelectorSerial >>= \(s,set)->syncSerialChannel s set decode encode ch ||- sendMsg msgs ch ||- ( (