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

@@ -74,7 +74,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;
k_mutex_t rx_lock;
@@ -105,27 +105,27 @@ typedef struct at_event_st {
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;
k_task_t parser;
at_cache_t recv_cache;
k_task_t parser;
at_cache_t recv_cache;
at_timer_t timer;
at_timer_t timer;
k_mutex_t global_lock;
k_mutex_t global_lock;
char *cmd_buf;
k_mutex_t cmd_buf_lock;
char *cmd_buf;
k_mutex_t cmd_buf_lock;
hal_uart_t uart;
k_mutex_t uart_tx_lock;
k_mutex_t uart_rx_lock;
k_sem_t uart_rx_sem;
k_fifo_t uart_rx_fifo;
uint8_t *uart_rx_fifo_buffer;
hal_uart_t uart;
k_mutex_t uart_tx_lock;
k_mutex_t uart_rx_lock;
k_sem_t uart_rx_sem;
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

@@ -34,7 +34,7 @@ __STATIC__ int at_uart_getchar(uint8_t *data, k_tick_t timeout)
return -1;
}
err = tos_fifo_pop(&AT_AGENT->uart_rx_fifo, data);
err = tos_chr_fifo_pop(&AT_AGENT->uart_rx_fifo, data);
tos_mutex_post(&AT_AGENT->uart_rx_lock);
@@ -549,7 +549,7 @@ __API__ int tos_at_channel_read(int channel_id, uint8_t *buffer, size_t buffer_l
return total_read_len;
}
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);
tos_mutex_post(&data_channel->rx_lock);
@@ -587,7 +587,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);
tos_mutex_post(&data_channel->rx_lock);
@@ -616,7 +616,7 @@ __API__ int tos_at_channel_write(int channel_id, uint8_t *buffer, size_t buffer_
return -1;
}
ret = tos_fifo_push_stream(&data_channel->rx_fifo, buffer, buffer_len);
ret = tos_chr_fifo_push_stream(&data_channel->rx_fifo, buffer, buffer_len);
tos_mutex_post(&data_channel->rx_lock);
@@ -637,7 +637,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;
@@ -702,7 +702,7 @@ __API__ int tos_at_channel_free(int channel_id)
tos_mutex_destroy(&data_channel->rx_lock);
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));
@@ -801,7 +801,7 @@ __API__ int tos_at_init(hal_uart_port_t uart_port, at_event_t *event_table, size
}
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, buffer, AT_UART_RX_FIFO_BUFFER_SIZE);
buffer = tos_mmheap_alloc(AT_CMD_BUFFER_SIZE);
if (!buffer) {
@@ -873,7 +873,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;
}
@@ -900,7 +900,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();
}
@@ -909,7 +909,7 @@ __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_sem_post(&AT_AGENT->uart_rx_sem);
}
}