适配系统适配层的更新
This commit is contained in:
@@ -14,17 +14,17 @@ static has_ptcl_handler *g_handler = NULL;
|
||||
static void has_receive_from_mcu(const has_tlv_t *box)
|
||||
{
|
||||
printf("receive event:%d\n", box->event);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
static void has_receive_from_mcu_1(const has_tlv_t *box)
|
||||
{
|
||||
printf("receive event:%d\n", box->event);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
static void has_receive_from_mcu_2(const has_tlv_t *box)
|
||||
{
|
||||
printf("receive event:%d\n", box->event);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
int acm_hal_send(uint8_t *buff, uint32_t len)
|
||||
@@ -47,10 +47,11 @@ void send_fail_callback(has_tlv_t *p_tlv)
|
||||
printf("event %x send fail\n", p_tlv->event);
|
||||
}
|
||||
|
||||
void *protocol_task(void *param)
|
||||
static void protocol_task(void *param)
|
||||
{
|
||||
int actuall_len;
|
||||
|
||||
(void)param;
|
||||
while (1)
|
||||
{
|
||||
/* reads */
|
||||
@@ -61,7 +62,6 @@ void *protocol_task(void *param)
|
||||
}
|
||||
has_sleep_ms(PROCESS_MSG_PERIOD);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void msg_handle_cb(unsigned char module_id, const unsigned char *buf, unsigned int len)
|
||||
@@ -72,9 +72,11 @@ static void msg_handle_cb(unsigned char module_id, const unsigned char *buf, uns
|
||||
}
|
||||
|
||||
|
||||
void *send_test_task(void *param)
|
||||
static void send_test_task(void *param)
|
||||
{
|
||||
unsigned char data = 3;
|
||||
|
||||
(void)param;
|
||||
while (1)
|
||||
{
|
||||
/* write */
|
||||
@@ -87,6 +89,22 @@ void *send_test_task(void *param)
|
||||
int example_protocol_init(void)
|
||||
{
|
||||
has_protocol_attr attr;
|
||||
has_task_attr_t protocol_task_attr = {
|
||||
.name = "acm_read",
|
||||
.entry = protocol_task,
|
||||
.arg = NULL,
|
||||
.stack_size_bytes = 1024U,
|
||||
.priority = HAS_TASK_PRIORITY_NORMAL,
|
||||
.linux_attr = { .sched_policy = -1 },
|
||||
};
|
||||
has_task_attr_t send_task_attr = {
|
||||
.name = "acm_send",
|
||||
.entry = send_test_task,
|
||||
.arg = NULL,
|
||||
.stack_size_bytes = 1024U,
|
||||
.priority = HAS_TASK_PRIORITY_NORMAL,
|
||||
.linux_attr = { .sched_policy = -1 },
|
||||
};
|
||||
kbox_event uart_list[] =
|
||||
{
|
||||
{TEST_EVENT, has_receive_from_mcu},
|
||||
@@ -102,21 +120,35 @@ int example_protocol_init(void)
|
||||
attr.success_cb = send_success_callback;
|
||||
attr.fail_cb = send_fail_callback;
|
||||
|
||||
if (read_buffer == NULL) {
|
||||
read_buffer = has_malloc(REC_BUFFER_LEN_MAX);
|
||||
if (read_buffer == NULL) {
|
||||
printf("alloc ACM read buffer failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
g_handler = has_protocol_create(&attr);
|
||||
if (g_handler == NULL)
|
||||
{
|
||||
printf("create ACM handler err!\n");
|
||||
return NULL;
|
||||
has_free(read_buffer);
|
||||
read_buffer = NULL;
|
||||
return -1;
|
||||
}
|
||||
printf("module:ACM\n");
|
||||
/* 创建线程 */
|
||||
if (has_task_create("read_test", TASK_PRIORITY_NORMAL, 1024, protocol_task, NULL, &protocol_tid) != 0) {
|
||||
printf("module:WIFI create task failed\n");
|
||||
if (has_task_create(&protocol_task_attr, &protocol_tid) != 0) {
|
||||
printf("module:ACM create read task failed\n");
|
||||
has_protocol_destroy(g_handler);
|
||||
g_handler = NULL;
|
||||
has_free(read_buffer);
|
||||
read_buffer = NULL;
|
||||
return -1;
|
||||
}
|
||||
if (has_task_create("send_test", TASK_PRIORITY_NORMAL, 1024, send_test_task, NULL, &send_test_tid) != 0) {
|
||||
printf("module:WIFI create task failed\n");
|
||||
return -1;
|
||||
if (has_task_create(&send_task_attr, &send_test_tid) != 0) {
|
||||
printf("module:ACM create send task failed\n");
|
||||
// return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user