同步更新示例
This commit is contained in:
@@ -387,7 +387,7 @@ int has_msg_publish(has_module_ID_e module_id, void *buffer, unsigned int length
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 处理一个消息,先入先出,(TODO:互斥)禁止在多个线程同时调用同一id的handle
|
* @brief 处理一个消息,先入先出
|
||||||
*
|
*
|
||||||
* @param module_id:处理消息的模块id号
|
* @param module_id:处理消息的模块id号
|
||||||
* @param cb:消息处理回调
|
* @param cb:消息处理回调
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#define MSG_OPT_OS_NONE_OR_OSAL 4
|
#define MSG_OPT_OS_NONE_OR_OSAL 4
|
||||||
#define MSG_OPT_OS_USER_DEFINED 5
|
#define MSG_OPT_OS_USER_DEFINED 5
|
||||||
|
|
||||||
/* TODO:rtt未测过 */
|
/* TODO:rtt未验证 */
|
||||||
#define MSG_OPT_OS MSG_OPT_OS_LINUX
|
#define MSG_OPT_OS MSG_OPT_OS_LINUX
|
||||||
// #define MSG_OPT_OS MSG_OPT_OS_freeRTOS
|
// #define MSG_OPT_OS MSG_OPT_OS_freeRTOS
|
||||||
// #define MSG_OPT_OS MSG_OPT_OS_RT_THREAD
|
// #define MSG_OPT_OS MSG_OPT_OS_RT_THREAD
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ void *gui_function(void *arg)
|
|||||||
has_msg_publish(GUI, gui_publish_buffer3, sizeof(gui_publish_buffer3)); // GUI发布第三条消息
|
has_msg_publish(GUI, gui_publish_buffer3, sizeof(gui_publish_buffer3)); // GUI发布第三条消息
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
usleep(500 * 1000);
|
// usleep(500 * 1000);
|
||||||
has_msg_handle(GUI, gui_handle_cb); // 处理一条GUI收到的消息,先入先出
|
has_msg_handle(GUI, gui_handle_cb, 500); // 处理一条GUI收到的消息,先入先出
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +63,9 @@ void *sensor_function(void *arg)
|
|||||||
has_msg_publish(moude_ID, sensor_publish_buffer2, sizeof(sensor_publish_buffer2)); // SENSOR发布第二条消息
|
has_msg_publish(moude_ID, sensor_publish_buffer2, sizeof(sensor_publish_buffer2)); // SENSOR发布第二条消息
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
usleep(500 * 1000);
|
// usleep(500 * 1000);
|
||||||
has_msg_handle(moude_ID, sensor_handle_cb); // 处理一条SENSOR收到的消息,先入先出
|
has_msg_handle(moude_ID, sensor_handle_cb, 500); // 处理一条SENSOR收到的消息,先入先出
|
||||||
has_msg_handle_latest(moude_ID, sensor_handle_cb); // 处理一条SENSOR最新收到的消息
|
has_msg_handle_latest(moude_ID, sensor_handle_cb, 0); // 处理一条SENSOR最新收到的消息
|
||||||
if (has_msg_is_message_empty(moude_ID) != 0) // 判断是否还有消息未处理
|
if (has_msg_is_message_empty(moude_ID) != 0) // 判断是否还有消息未处理
|
||||||
{
|
{
|
||||||
printf("模块:%d 还有%d条消息待处理\n", moude_ID, has_msg_get_message_number(moude_ID));
|
printf("模块:%d 还有%d条消息待处理\n", moude_ID, has_msg_get_message_number(moude_ID));
|
||||||
|
|||||||
Reference in New Issue
Block a user