You need to sign in or sign up before continuing.
Commit 8cd573f4 authored by 957dd's avatar 957dd

修改了日志和线程函数的部分bug

parent 317fa7c0
......@@ -4,7 +4,7 @@ int main()
{
if (mylog_init() != 0)
{
my_zlog_error("日志初始化失败,错误代码:%d", mylog_init());
my_zlog_error("日志初始化失败,错误代码");
return -1;
}
......
......@@ -299,12 +299,14 @@ void *thread_play_mp3(void *arg)
return NULL;
}
// 方向盘控制线程:100ms周期调用平滑处理
// 方向盘控制线程:25ms周期调用平滑处理,无匹配设备时自动退出
void *thread_steering_control(void *arg)
{
my_zlog_info("steering_pthread");
while(1) {
steering_control_process();
if (!steering_control_process()) {
break;
}
delay_ms(25);
}
return NULL;
......
No preview for this file type
......@@ -3,16 +3,7 @@
#include "gpio_common.h"
static SteeringControl s_steering_devices[] = {
{DEVICE_CAR0101, "car0101", NULL, NULL},
{DEVICE_CAR0102, "car0102", car0102_control_steering_change_process, car0102_steering_smooth_all},
{DEVICE_CAR0103, "car0103", NULL, NULL},
{DEVICE_CAR0104, "car0104", NULL, NULL},
{DEVICE_CAR0105, "car0105", NULL, NULL},
{DEVICE_TANK0202, "tank0202", NULL, NULL},
{DEVICE_TANK0203, "tank0203", NULL, NULL},
{DEVICE_TANK0204, "tank0204", NULL, NULL},
{DEVICE_TANK0206, "tank0206", NULL, NULL},
{DEVICE_TANK0207, "tank0207", NULL, NULL},
{0, "unknown", NULL, NULL}
};
......@@ -29,15 +20,21 @@ SteeringControl* get_steering_control(void)
}
// 线程调用:通过结构体分发到对应设备的平滑处理函数
void steering_control_process(void) {
bool steering_control_process(void) {
static SteeringControl *ctrl = NULL;
if (ctrl == NULL) {
my_zlog_info("steering_control_process: ctrl is NULL");
static bool s_initialized = false;
if (!s_initialized) {
ctrl = get_steering_control();
s_initialized = true;
if (ctrl == NULL) {
my_zlog_info("当前设备无方向盘控制,线程退出");
return false;
}
}
if (ctrl && ctrl->smooth_process_func) {
ctrl->smooth_process_func();
}
return true;
}
// MQTT调用:通过结构体分发到对应设备的方向盘接收函数
......
......@@ -12,7 +12,7 @@ typedef struct {
SteeringControl* get_steering_control(void);
void steering_control_process(void);
bool steering_control_process(void);
void steering_mqtt_recv(cJSON *body);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment