add ring queue/message queue/mail queue, binary heap/priority queue/priority message queue/priority mail queue

1. remove the old msg queue and queue:
i. msg queue is not a common and reusable/flexible component(need user to config the msg pool size and this componet can only be used by tos_queue)
ii. tos_queue can only deliver the pointer message(cannot do a memory buffer deliver)

2. add ring queue(tos_ring_q) componet
rinq queue can be reused by tos_chr_fifi/tos_msg_q/tos_mail_q as the foundational data container

3. add message queue(tos_msg_q)
a little like the old queue mechanism, supply the capability to deliver a pointer message

4. add mail queue(tos_mail_q)
supply the capability to deliver a memory buffer

5. add binary heap(tos_bin_heap)
the basement componet to implement priority queue

6. add priority queue(tos_prio_q)
can be reused by the priority message/mail queue  as the foundational data container.

7. add priority message queue(tos_prio_msg_q)
a message(pointer) deliver mechanism, supply the capability of delivering the message with priority(message with higher priority comes faster to the pender than with lower)

8. add priority mail queue(tos_prio_mail_q)
a mail(memory buffer) deliver mechanism, supply the capability of delivering the mail with priority(mail with higher priority comes faster to the pender than with lower)
This commit is contained in:
daishengdong
2019-10-28 15:50:46 +08:00
parent f35b725a59
commit d0b8d0675e
127 changed files with 26661 additions and 14013 deletions

View File

@@ -82,7 +82,7 @@ typedef enum at_channel_status_en {
typedef struct at_data_channel_st {
uint8_t is_free;
k_fifo_t rx_fifo;
k_chr_fifo_t rx_fifo;
uint8_t *rx_fifo_buffer;
at_channel_status_t status;
@@ -115,21 +115,21 @@ typedef struct at_agent_st {
at_data_channel_t data_channel[AT_DATA_CHANNEL_NUM];
at_event_t *event_table;
size_t event_table_size;
at_event_t *event_table;
size_t event_table_size;
at_echo_t *echo;
at_echo_t *echo;
at_cache_t recv_cache;
at_cache_t recv_cache;
at_timer_t timer;
at_timer_t timer;
char *cmd_buf;
char *cmd_buf;
hal_uart_t uart;
hal_uart_t uart;
k_fifo_t uart_rx_fifo;
uint8_t *uart_rx_fifo_buffer;
k_chr_fifo_t uart_rx_fifo;
uint8_t *uart_rx_fifo_buffer;
} at_agent_t;
#define AT_AGENT ((at_agent_t *)(&at_agent))

View File

@@ -8,7 +8,7 @@ __STATIC__ int at_uart_getchar(uint8_t *data, k_tick_t timeout)
at_delay(1);
err = tos_fifo_pop(&AT_AGENT->uart_rx_fifo, data);
err = tos_chr_fifo_pop(&AT_AGENT->uart_rx_fifo, data);
return err == K_ERR_NONE ? 0 : -1;
}
@@ -315,7 +315,7 @@ __API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_l
}
while (K_TRUE) {
read_len = tos_fifo_pop_stream(&data_channel->rx_fifo, buffer, buffer_len);
read_len = tos_chr_fifo_pop_stream(&data_channel->rx_fifo, buffer, buffer_len);
total_read_len += read_len;
if (total_read_len < buffer_len) {
@@ -347,7 +347,7 @@ __API__ int tos_at_channel_read_timed(int channel_id, uint8_t *buffer, size_t bu
return total_read_len;
}
read_len = tos_fifo_pop_stream(&data_channel->rx_fifo, buffer + read_len, buffer_len - total_read_len);
read_len = tos_chr_fifo_pop_stream(&data_channel->rx_fifo, buffer + read_len, buffer_len - total_read_len);
total_read_len += read_len;
if (total_read_len < buffer_len) {
@@ -369,7 +369,7 @@ __API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_
return -1;
}
return tos_fifo_push_stream(&data_channel->rx_fifo, buffer, buffer_len);
return tos_chr_fifo_push_stream(&data_channel->rx_fifo, buffer, buffer_len);
}
__STATIC_INLINE__ int at_channel_construct(at_data_channel_t *data_channel, const char *ip, const char *port)
@@ -382,7 +382,7 @@ __STATIC_INLINE__ int at_channel_construct(at_data_channel_t *data_channel, cons
}
data_channel->rx_fifo_buffer = fifo_buffer;
tos_fifo_create(&data_channel->rx_fifo, fifo_buffer, AT_DATA_CHANNEL_FIFO_BUFFER_SIZE);
tos_chr_fifo_create(&data_channel->rx_fifo, fifo_buffer, AT_DATA_CHANNEL_FIFO_BUFFER_SIZE);
data_channel->remote_ip = ip;
data_channel->remote_port = port;
@@ -441,7 +441,7 @@ __API__ int tos_at_channel_free(int channel_id)
}
tos_mmheap_free(data_channel->rx_fifo_buffer);
tos_fifo_destroy(&data_channel->rx_fifo);
tos_chr_fifo_destroy(&data_channel->rx_fifo);
memset(data_channel, 0, sizeof(at_data_channel_t));
@@ -542,7 +542,7 @@ __API__ int tos_at_init(hal_uart_port_t uart_port, evtdrv_task_id_t at_task_id,
}
AT_AGENT->uart_rx_fifo_buffer = (uint8_t *)buffer;
tos_fifo_create(&AT_AGENT->uart_rx_fifo, (uint8_t *)buffer, AT_UART_RX_FIFO_BUFFER_SIZE);
tos_chr_fifo_create(&AT_AGENT->uart_rx_fifo, (uint8_t *)buffer, AT_UART_RX_FIFO_BUFFER_SIZE);
buffer = tos_mmheap_alloc(AT_CMD_BUFFER_SIZE);
if (!buffer) {
@@ -570,7 +570,7 @@ errout1:
errout0:
tos_mmheap_free(AT_AGENT->uart_rx_fifo_buffer);
AT_AGENT->uart_rx_fifo_buffer = K_NULL;
tos_fifo_destroy(&AT_AGENT->uart_rx_fifo);
tos_chr_fifo_destroy(&AT_AGENT->uart_rx_fifo);
return -1;
}
@@ -587,7 +587,7 @@ __API__ void tos_at_deinit(void)
tos_mmheap_free(AT_AGENT->uart_rx_fifo_buffer);
AT_AGENT->uart_rx_fifo_buffer = K_NULL;
tos_fifo_destroy(&AT_AGENT->uart_rx_fifo);
tos_chr_fifo_destroy(&AT_AGENT->uart_rx_fifo);
at_channel_deinit();
}
@@ -596,9 +596,9 @@ __API__ void tos_at_deinit(void)
hal(driver framework), that would be a huge work, we place it in future plans. */
__API__ void tos_at_uart_write_byte(uint8_t data)
{
if (tos_fifo_push(&AT_AGENT->uart_rx_fifo, data) == K_ERR_NONE) {
if (tos_chr_fifo_push(&AT_AGENT->uart_rx_fifo, data) == K_ERR_NONE) {
tos_evtdrv_event_set(AT_AGENT->at_task_id, EVENT_AT_UART_INCOMING);
}
}
}
__STATIC__ void at_echo_event_emit(at_echo_t *echo)