repositories
/
mTask.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed communication
[mTask.git]
/
int
/
task.c
diff --git
a/int/task.c
b/int/task.c
index
3b5690a
..
a08e791
100644
(file)
--- a/
int/task.c
+++ b/
int/task.c
@@
-1,15
+1,22
@@
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+
+#ifndef STM
#include <unistd.h>
#include <unistd.h>
+#include <stdio.h>
+#endif
-#include "misc.h"
#include "task.h"
#include "task.h"
+#include "interface.h"
-struct task tasks[MAXTASKS];// = {0};
-uint8_t c;
+struct task tasks[MAXTASKS];
-int task_register(int fd)
+void task_init(void)
+{
+ memset(&tasks, 0, sizeof(struct task)*MAXTASKS);
+}
+
+int task_register(void)
{
uint8_t ct;
{
uint8_t ct;
@@
-17,32
+24,35
@@
int task_register(int fd)
if(!tasks[ct].used)
break;
if(ct == MAXTASKS)
if(!tasks[ct].used)
break;
if(ct == MAXTASKS)
- die("Trying to add too much tasks...
\n
");
+ die("Trying to add too much tasks...");
memset(&tasks[ct], 0, sizeof(struct task));
//Read interval
memset(&tasks[ct], 0, sizeof(struct task));
//Read interval
-
read16(fd, c, tasks[ct].interval
);
+
tasks[ct].interval = read16(
);
//Read tasklength
//Read tasklength
- read16(fd, c, tasks[ct].tlen);
+ tasks[ct].tlen = read16();
+ debug("task interval: %d, length: %d\n",
+ tasks[ct].interval, tasks[ct].tlen);
if(tasks[ct].tlen > MAXTASKSIZE)
if(tasks[ct].tlen > MAXTASKSIZE)
- die("Task is too long: %d
\n
", tasks[ct].tlen);
+ die("Task is too long: %d", tasks[ct].tlen);
//Read task bytecode
//Read task bytecode
- for(int i = 0; i<tasks[ct].tlen; i++){
-
read(fd, tasks[ct].bc+i, 1
);
- debug("t[][%i]: 0x%02x %d
\n
", i,
+ for(
unsigned
int i = 0; i<tasks[ct].tlen; i++){
+
tasks[ct].bc[i] = read_byte(
);
+ debug("t[][%i]: 0x%02x %d", i,
tasks[ct].bc[i], tasks[ct].bc[i]);
}
//Return the task number for later removal
tasks[ct].bc[i], tasks[ct].bc[i]);
}
//Return the task number for later removal
- debug("Received a task of length %d
\n
", tasks[ct].tlen);
+ debug("Received a task of length %d", tasks[ct].tlen);
tasks[ct].used = true;
tasks[ct].used = true;
+ tasks[ct].lastrun = 0L;
+
return ct;
}
return ct;
}
-void task_delete(
int f
d)
+void task_delete(
voi
d)
{
{
- read(fd, &c, 1);
- tasks[c].used = false;
+ tasks[read_byte()].used = false;
}
struct task *task_get(int num)
}
struct task *task_get(int num)