From: Mart Lubbers Date: Thu, 16 Mar 2017 18:36:45 +0000 (+0100) Subject: add specification sending X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=a8b74f431274acab9369d983f0dfed64333dea9f;p=mTask.git add specification sending --- diff --git a/client/Makefile.linux b/client/Makefile.linux index 55e2e44..fb97f4d 100644 --- a/client/Makefile.linux +++ b/client/Makefile.linux @@ -1,4 +1,4 @@ -CFLAGS:=-g -Wall -Wextra -DDEBUG +CFLAGS:=-DLINUX -g -Wall -Wextra -DDEBUG PROG:=main OBJS:=interpret.o sds.o task.o main.o interface.o spec.o diff --git a/client/interface.h b/client/interface.h index f3920eb..eee3457 100644 --- a/client/interface.h +++ b/client/interface.h @@ -5,30 +5,51 @@ #include #include -#ifndef STM +#ifdef LINUX +#define MAXTASKS 5 +#define MAXSDSS 100 +#define HAVELED 1 +#define HAVEAIO 1 +#define HAVEDIO 1 + extern int gargc; extern char **gargv; + +#elif defined STM +#define MAXTASKS 5 +#define MAXSDSS 100 +#define HAVELED 1 +#define HAVEAIO 1 +#define HAVEDIO 1 + +#else +//Add you device here #endif #define read16() 256*(uint8_t)read_byte() + (uint8_t)read_byte() #define from16(a, b) 256*a+b #define write16(i) { write_byte((uint8_t)i/256); write_byte((uint8_t)i%256); } + +/* Communication */ +bool input_available(void); uint8_t read_byte(void); void write_byte(uint8_t b); +/* Analog and digital pins */ void write_dpin(uint8_t i, bool b); bool read_dpin(uint8_t i); - void write_apin(uint8_t i, uint8_t a); uint8_t read_apin(uint8_t i); +/* UserLED */ void led_on(uint8_t i); void led_off(uint8_t i); +/* Delay and communication */ long millis(void); -bool input_available(void); void delay(long ms); +/* Auxilliary */ void setup(void); void debug(char *fmt, ...); void pdie(char *s); diff --git a/client/sds.h b/client/sds.h index de83421..4179f47 100644 --- a/client/sds.h +++ b/client/sds.h @@ -3,8 +3,6 @@ #include -#define MAXSDSS 100 - struct sds { int id; bool used; diff --git a/client/spec.c b/client/spec.c index 7bf8576..6fb66be 100644 --- a/client/spec.c +++ b/client/spec.c @@ -1,4 +1,10 @@ //TODO -void spec_send(void){ +#include "spec.h" +#include "interface.h" +void spec_send(void) +{ + write_byte(0 | HAVELED << 0 | HAVEAIO << 1 | HAVEDIO << 2); + write_byte(MAXTASKS); + write_byte(MAXSDSS); } diff --git a/client/spec.h b/client/spec.h index 0007dc3..a8e0d7d 100644 --- a/client/spec.h +++ b/client/spec.h @@ -4,14 +4,6 @@ #include #include -struct device_spec { - bool have_led; - bool have_aio; - bool have_dio; - uint8_t max_tasks; - uint8_t max_sds; -}; - void spec_send(void); #endif diff --git a/client/task.c b/client/task.c index dfdb71b..0d9b125 100644 --- a/client/task.c +++ b/client/task.c @@ -1,12 +1,8 @@ #include #include -#ifndef STM -#include -#include -#endif - #include "task.h" +#include "spec.h" #include "interface.h" struct task tasks[MAXTASKS]; diff --git a/client/task.h b/client/task.h index 6c7dfd3..a6c02b7 100644 --- a/client/task.h +++ b/client/task.h @@ -1,7 +1,6 @@ #ifndef TASK_H #define TASK_H -#define MAXTASKS 5 #define MAXTASKSIZE 1024 #include