Commit 20d1604c authored by 学习的菜鸟's avatar 学习的菜鸟

无验证,解决了一些bug

parent 65d8e6aa
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(car project(car
VERSION 1.2.0 VERSION 1.2.1
LANGUAGES C LANGUAGES C
) )
......
...@@ -11,6 +11,10 @@ int main(){ ...@@ -11,6 +11,10 @@ int main(){
return -2; return -2;
} }
if(audio_init()!=0){
my_zlog_warn("audio初始化有问题");
}
if(device_id_file_init()!=0){ if(device_id_file_init()!=0){
my_zlog_error("设备id读取失败"); my_zlog_error("设备id读取失败");
return -3; return -3;
...@@ -34,10 +38,6 @@ int main(){ ...@@ -34,10 +38,6 @@ int main(){
my_zlog_warn("此版本电压没有使用INA226"); my_zlog_warn("此版本电压没有使用INA226");
} }
if(audio_init()!=0){
my_zlog_warn("audio初始化有问题");
}
int thread_rc=thread_start_init( thread_exit_time,thread_mqtt_beat,thread_open_browser,thread_mqtt_reconnect,thread_time_calculation,thread_play_mp3); int thread_rc=thread_start_init( thread_exit_time,thread_mqtt_beat,thread_open_browser,thread_mqtt_reconnect,thread_time_calculation,thread_play_mp3);
if(thread_rc != 0){ if(thread_rc != 0){
my_zlog_warn("多线程初始化失败"); my_zlog_warn("多线程初始化失败");
......
...@@ -135,6 +135,7 @@ void *thread_time_calculation(void *arg) { ...@@ -135,6 +135,7 @@ void *thread_time_calculation(void *arg) {
//专门处理MP3播放 //专门处理MP3播放
void *thread_play_mp3(void* arg) { void *thread_play_mp3(void* arg) {
audio_init();
audioplay_cycle(); audioplay_cycle();
return NULL; return NULL;
} }
......
No preview for this file type
...@@ -7,8 +7,6 @@ void tank0203_middle(); ...@@ -7,8 +7,6 @@ void tank0203_middle();
void tank0203_change(unsigned char *buf); void tank0203_change(unsigned char *buf);
int tank_shot_back_stop(int pin,int val);
/*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/ /*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/
void tank0203_thread_close(); void tank0203_thread_close();
#endif #endif
\ No newline at end of file
...@@ -3,14 +3,13 @@ ...@@ -3,14 +3,13 @@
#include "gpio_init.h" #include "gpio_init.h"
#include "pthrpoll.h" #include "pthrpoll.h"
_Thread_local const tank_common_back *g_tank_common_config_t = NULL; int tank_shot_back_stop(unsigned char pin,unsigned char val);
const tank_common_back *g_tank_common_config_t = NULL;
long long shot_device_time_start =0 ; long long shot_device_time_start =0 ;
long long shot_device_time_end = 0; long long shot_device_time_end = 0;
int tank_shot_back_stop(int pin,int val);
void tank_shot_back(unsigned char gval) { void tank_shot_back(unsigned char gval) {
if (gval < 50) { if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75); pwmWrite(PWM_PIN_CHANGE, 75);
...@@ -72,6 +71,7 @@ const tank_common_back tank_common_config_t[]={ ...@@ -72,6 +71,7 @@ const tank_common_back tank_common_config_t[]={
}; };
void tank_shot_back_stop_task_function(void *arg) {//多线程处理坦克发射后退线程池 void tank_shot_back_stop_task_function(void *arg) {//多线程处理坦克发射后退线程池
while(1){ while(1){
long long interval=shot_device_time_start-shot_device_time_end; long long interval=shot_device_time_start-shot_device_time_end;
if(g_device_delay_count > g_tank_common_config_t->back_time&&g_device_delay_count < (g_tank_common_config_t->back_time+30)) if(g_device_delay_count > g_tank_common_config_t->back_time&&g_device_delay_count < (g_tank_common_config_t->back_time+30))
...@@ -98,7 +98,7 @@ void tank_shot_pthrpoll_task_init(){ ...@@ -98,7 +98,7 @@ void tank_shot_pthrpoll_task_init(){
my_zlog_debug("线程池打开"); my_zlog_debug("线程池打开");
} }
int tank_shot_back_stop(int pin,int val){ int tank_shot_back_stop(unsigned char pin,unsigned char val){
static int shot_count=0; static int shot_count=0;
shot_device_time_start=get_current_time_millis(); shot_device_time_start=get_current_time_millis();
if(pin !=27){ if(pin !=27){
...@@ -129,7 +129,8 @@ void tank_thread_close(){ ...@@ -129,7 +129,8 @@ void tank_thread_close(){
thread_pool_destroy(pool_tank_t); thread_pool_destroy(pool_tank_t);
} }
void tank_shot_stop_control(int device_id,int pin,int val) { void tank_shot_stop_control(int device_id,unsigned char pin,unsigned char val) {
if (!g_tank_common_config_t || g_tank_common_config_t->device_id != device_id) { if (!g_tank_common_config_t || g_tank_common_config_t->device_id != device_id) {
// 查找设备配置 // 查找设备配置
for(int i = 0; tank_common_config_t[i].device_id != -1; i++) { for(int i = 0; tank_common_config_t[i].device_id != -1; i++) {
...@@ -144,8 +145,6 @@ void tank_shot_stop_control(int device_id,int pin,int val) { ...@@ -144,8 +145,6 @@ void tank_shot_stop_control(int device_id,int pin,int val) {
my_zlog_error("Error: Device stop ID %d not found!\n", device_id); my_zlog_error("Error: Device stop ID %d not found!\n", device_id);
return; return;
} }
g_tank_common_config_t->shot_back(pin,val); g_tank_common_config_t->shot_back(pin,val);
} }
\ No newline at end of file
...@@ -8,10 +8,10 @@ typedef struct { ...@@ -8,10 +8,10 @@ typedef struct {
int back_time; int back_time;
int back_interval_back; int back_interval_back;
int shot_back_speed; int shot_back_speed;
int(*shot_back)(int pin,int val); int(*shot_back)(unsigned char pin,unsigned char val);
} tank_common_back; } tank_common_back;
void tank_shot_stop_control(int device_id,int pin,int val); void tank_shot_stop_control(int device_id,unsigned char pin,unsigned char val);
void tank_thread_close(); void tank_thread_close();
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#include "gpio_init.h" #include "gpio_init.h"
#include "device_init.h" #include "device_init.h"
int g_heartbeat_count=0; int g_heartbeat_count=0;
int g_devcontrol_exit_count=0; int g_devcontrol_exit_count=0;
...@@ -171,6 +169,7 @@ void message_4(cJSON *body){//message 为4时候 ...@@ -171,6 +169,7 @@ void message_4(cJSON *body){//message 为4时候
pin_value(g_valt[1],g_valt[2]); pin_value(g_valt[1],g_valt[2]);
pwm_value(g_valt[1],g_valt[2]); pwm_value(g_valt[1],g_valt[2]);
tank_shot_stop_control(g_device_type,g_valt[1],g_valt[2]); tank_shot_stop_control(g_device_type,g_valt[1],g_valt[2]);
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "cjson/cJSON.h" #include "cjson/cJSON.h"
/*TRUE为打开验证,FALSE为关闭验证*/ /*TRUE为打开验证,FALSE为关闭验证*/
#define VERIFIED_MODE TRUE #define VERIFIED_MODE FALSE
#define AES_BLOCK_SIZE 16 #define AES_BLOCK_SIZE 16
......
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