|
@@ -1,35 +1,36 @@
|
|
|
#include "thread.h"
|
|
#include "thread.h"
|
|
|
|
|
|
|
|
static thread_attr_t thdAttrs[THREAD_ID_MAX]={
|
|
static thread_attr_t thdAttrs[THREAD_ID_MAX]={
|
|
|
- //name fn arg stacksize prio
|
|
|
|
|
- {"io", NULL, NULL, 8*MB, 1},
|
|
|
|
|
- {"ws", ws_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"web", web_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"ntp", ntp_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"snmp", snmp_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"power", power_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"sensor", sensor_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"polling", polling_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"cascade", cascade_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"casscan", cascade_scan_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"shmw", shm_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"breaker", breaker_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"switch", netswitch_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"brkscan", breaker_scanner_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"mqtt", mqtt_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"mail", mail_thread, NULL, 8*MB, 1},
|
|
|
|
|
- {"modbus_tcp", tcp_modbus_thread, NULL, 8*MB, 1},
|
|
|
|
|
|
|
+ //name fn arg stacksize prio
|
|
|
|
|
+ {"io", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"ws", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"web", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"ntp", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"snmp", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"power", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"sensor", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"polling", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"cascade", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"casscan", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"shmw", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"breaker", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"switch", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"brkscan", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"mqtt", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"mail", NULL, NULL, 8*MB, 1},
|
|
|
|
|
+ {"modbus_tcp", NULL, NULL, 8*MB, 1},
|
|
|
};
|
|
};
|
|
|
static thread_handle_t thdHandles[THREAD_ID_MAX]={0};
|
|
static thread_handle_t thdHandles[THREAD_ID_MAX]={0};
|
|
|
|
|
|
|
|
|
|
|
|
|
-int thread_start(int id, void *arg)
|
|
|
|
|
|
|
+int thread_start(int id, thread_fn fn, void *arg)
|
|
|
{
|
|
{
|
|
|
- if(id<0 || id>=THREAD_ID_MAX) {
|
|
|
|
|
|
|
+ if(id<0 || id>=THREAD_ID_MAX || !fn) {
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
thread_attr_t *attr=&thdAttrs[id];
|
|
thread_attr_t *attr=&thdAttrs[id];
|
|
|
|
|
|
|
|
|
|
+ attr->fn = fn;
|
|
|
attr->arg = arg;
|
|
attr->arg = arg;
|
|
|
return thread_startEx(id, attr->name, attr->fn, attr->arg, attr->stksz, attr->prio);
|
|
return thread_startEx(id, attr->name, attr->fn, attr->arg, attr->stksz, attr->prio);
|
|
|
}
|
|
}
|
|
@@ -41,6 +42,9 @@ int thread_restart(int id)
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
thread_attr_t *attr=&thdAttrs[id];
|
|
thread_attr_t *attr=&thdAttrs[id];
|
|
|
|
|
+ if(!attr->fn) {
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
thread_stop(id);
|
|
thread_stop(id);
|
|
|
return thread_startEx(id, attr->name, attr->fn, attr->arg, attr->stksz, attr->prio);
|
|
return thread_startEx(id, attr->name, attr->fn, attr->arg, attr->stksz, attr->prio);
|