Commit bfad18a5 authored by 957dd's avatar 957dd

Merge branch 'feature/add_tank0203' into 'master'

Feature/add tank0203 See merge request !49
parents e660b5a2 a2419b28
...@@ -95,6 +95,7 @@ int hash_insert_init(HashTable_t *HashTable_t) { ...@@ -95,6 +95,7 @@ int hash_insert_init(HashTable_t *HashTable_t) {
insert(HashTable_t, "0104", CAR_0104); insert(HashTable_t, "0104", CAR_0104);
insert(HashTable_t, "0201", TANK_0201); insert(HashTable_t, "0201", TANK_0201);
insert(HashTable_t, "0202", TANK_0202); insert(HashTable_t, "0202", TANK_0202);
insert(HashTable_t, "0203", TANK_0203);
insert(HashTable_t, "0301", SHIP_0301); insert(HashTable_t, "0301", SHIP_0301);
insert(HashTable_t, "0401", PAO_0401); insert(HashTable_t, "0401", PAO_0401);
} }
...@@ -115,6 +116,9 @@ int device_judg(CodeEnum_t code,char *sub_str) { ...@@ -115,6 +116,9 @@ int device_judg(CodeEnum_t code,char *sub_str) {
}else if(code == TANK_0202) { }else if(code == TANK_0202) {
device_init(DEVICE_TANK0202); device_init(DEVICE_TANK0202);
my_zlog_info("使用型号%s",sub_str); my_zlog_info("使用型号%s",sub_str);
}else if(code == TANK_0203) {
device_init(DEVICE_TANK0203);
my_zlog_info("使用型号%s",sub_str);
}else if(code ==PAO_0401) { }else if(code ==PAO_0401) {
device_init(DEVICE_PAO_PTZ0401); device_init(DEVICE_PAO_PTZ0401);
my_zlog_info("使用型号%s",sub_str); my_zlog_info("使用型号%s",sub_str);
......
...@@ -14,6 +14,7 @@ typedef enum { ...@@ -14,6 +14,7 @@ typedef enum {
CAR_0104, CAR_0104,
TANK_0201, TANK_0201,
TANK_0202, TANK_0202,
TANK_0203,
SHIP_0301, SHIP_0301,
PAO_0401 PAO_0401
} CodeEnum_t; } CodeEnum_t;
......
...@@ -69,7 +69,7 @@ void *thread_mqtt_beat(void *arg) { ...@@ -69,7 +69,7 @@ void *thread_mqtt_beat(void *arg) {
g_heartbeat_count++; g_heartbeat_count++;
if(g_mqtt_grc == 0){ if(g_mqtt_grc == 0){
mqtt_wirte();//心跳,3s一个 mqtt_beat_wirte();//心跳,3s一个
} }
} }
return NULL; return NULL;
......
...@@ -654,29 +654,77 @@ drivers/devicecontrol/ptz0401_control.c.s: ...@@ -654,29 +654,77 @@ drivers/devicecontrol/ptz0401_control.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/ptz0401_control.c.s $(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/ptz0401_control.c.s
.PHONY : drivers/devicecontrol/ptz0401_control.c.s .PHONY : drivers/devicecontrol/ptz0401_control.c.s
drivers/devicecontrol/tank02002_control.o: drivers/devicecontrol/tank02002_control.c.o drivers/devicecontrol/tank0202_control.o: drivers/devicecontrol/tank0202_control.c.o
.PHONY : drivers/devicecontrol/tank02002_control.o .PHONY : drivers/devicecontrol/tank0202_control.o
# target to build an object file # target to build an object file
drivers/devicecontrol/tank02002_control.c.o: drivers/devicecontrol/tank0202_control.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank02002_control.c.o $(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0202_control.c.o
.PHONY : drivers/devicecontrol/tank02002_control.c.o .PHONY : drivers/devicecontrol/tank0202_control.c.o
drivers/devicecontrol/tank02002_control.i: drivers/devicecontrol/tank02002_control.c.i drivers/devicecontrol/tank0202_control.i: drivers/devicecontrol/tank0202_control.c.i
.PHONY : drivers/devicecontrol/tank02002_control.i .PHONY : drivers/devicecontrol/tank0202_control.i
# target to preprocess a source file # target to preprocess a source file
drivers/devicecontrol/tank02002_control.c.i: drivers/devicecontrol/tank0202_control.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank02002_control.c.i $(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0202_control.c.i
.PHONY : drivers/devicecontrol/tank02002_control.c.i .PHONY : drivers/devicecontrol/tank0202_control.c.i
drivers/devicecontrol/tank02002_control.s: drivers/devicecontrol/tank02002_control.c.s drivers/devicecontrol/tank0202_control.s: drivers/devicecontrol/tank0202_control.c.s
.PHONY : drivers/devicecontrol/tank02002_control.s .PHONY : drivers/devicecontrol/tank0202_control.s
# target to generate assembly for a file # target to generate assembly for a file
drivers/devicecontrol/tank02002_control.c.s: drivers/devicecontrol/tank0202_control.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank02002_control.c.s $(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0202_control.c.s
.PHONY : drivers/devicecontrol/tank02002_control.c.s .PHONY : drivers/devicecontrol/tank0202_control.c.s
drivers/devicecontrol/tank0203_control.o: drivers/devicecontrol/tank0203_control.c.o
.PHONY : drivers/devicecontrol/tank0203_control.o
# target to build an object file
drivers/devicecontrol/tank0203_control.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0203_control.c.o
.PHONY : drivers/devicecontrol/tank0203_control.c.o
drivers/devicecontrol/tank0203_control.i: drivers/devicecontrol/tank0203_control.c.i
.PHONY : drivers/devicecontrol/tank0203_control.i
# target to preprocess a source file
drivers/devicecontrol/tank0203_control.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0203_control.c.i
.PHONY : drivers/devicecontrol/tank0203_control.c.i
drivers/devicecontrol/tank0203_control.s: drivers/devicecontrol/tank0203_control.c.s
.PHONY : drivers/devicecontrol/tank0203_control.s
# target to generate assembly for a file
drivers/devicecontrol/tank0203_control.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0203_control.c.s
.PHONY : drivers/devicecontrol/tank0203_control.c.s
drivers/devicecontrol/tank_common.o: drivers/devicecontrol/tank_common.c.o
.PHONY : drivers/devicecontrol/tank_common.o
# target to build an object file
drivers/devicecontrol/tank_common.c.o:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank_common.c.o
.PHONY : drivers/devicecontrol/tank_common.c.o
drivers/devicecontrol/tank_common.i: drivers/devicecontrol/tank_common.c.i
.PHONY : drivers/devicecontrol/tank_common.i
# target to preprocess a source file
drivers/devicecontrol/tank_common.c.i:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank_common.c.i
.PHONY : drivers/devicecontrol/tank_common.c.i
drivers/devicecontrol/tank_common.s: drivers/devicecontrol/tank_common.c.s
.PHONY : drivers/devicecontrol/tank_common.s
# target to generate assembly for a file
drivers/devicecontrol/tank_common.c.s:
$(MAKE) $(MAKESILENT) -f CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank_common.c.s
.PHONY : drivers/devicecontrol/tank_common.c.s
drivers/gpio/device_init.o: drivers/gpio/device_init.c.o drivers/gpio/device_init.o: drivers/gpio/device_init.c.o
.PHONY : drivers/gpio/device_init.o .PHONY : drivers/gpio/device_init.o
...@@ -1726,9 +1774,15 @@ help: ...@@ -1726,9 +1774,15 @@ help:
@echo "... drivers/devicecontrol/ptz0401_control.o" @echo "... drivers/devicecontrol/ptz0401_control.o"
@echo "... drivers/devicecontrol/ptz0401_control.i" @echo "... drivers/devicecontrol/ptz0401_control.i"
@echo "... drivers/devicecontrol/ptz0401_control.s" @echo "... drivers/devicecontrol/ptz0401_control.s"
@echo "... drivers/devicecontrol/tank02002_control.o" @echo "... drivers/devicecontrol/tank0202_control.o"
@echo "... drivers/devicecontrol/tank02002_control.i" @echo "... drivers/devicecontrol/tank0202_control.i"
@echo "... drivers/devicecontrol/tank02002_control.s" @echo "... drivers/devicecontrol/tank0202_control.s"
@echo "... drivers/devicecontrol/tank0203_control.o"
@echo "... drivers/devicecontrol/tank0203_control.i"
@echo "... drivers/devicecontrol/tank0203_control.s"
@echo "... drivers/devicecontrol/tank_common.o"
@echo "... drivers/devicecontrol/tank_common.i"
@echo "... drivers/devicecontrol/tank_common.s"
@echo "... drivers/gpio/device_init.o" @echo "... drivers/gpio/device_init.o"
@echo "... drivers/gpio/device_init.i" @echo "... drivers/gpio/device_init.i"
@echo "... drivers/gpio/device_init.s" @echo "... drivers/gpio/device_init.s"
......
No preview for this file type
...@@ -6,8 +6,8 @@ CMAKE_PROGRESS_5 = ...@@ -6,8 +6,8 @@ CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = 82 CMAKE_PROGRESS_7 = 82
CMAKE_PROGRESS_8 = CMAKE_PROGRESS_8 =
CMAKE_PROGRESS_9 = CMAKE_PROGRESS_9 = 83
CMAKE_PROGRESS_10 = 83 CMAKE_PROGRESS_10 =
CMAKE_PROGRESS_11 = CMAKE_PROGRESS_11 =
CMAKE_PROGRESS_12 = 84 CMAKE_PROGRESS_12 = 84
CMAKE_PROGRESS_13 = CMAKE_PROGRESS_13 =
......
...@@ -6,8 +6,8 @@ CMAKE_PROGRESS_5 = ...@@ -6,8 +6,8 @@ CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = 3 CMAKE_PROGRESS_7 = 3
CMAKE_PROGRESS_8 = CMAKE_PROGRESS_8 =
CMAKE_PROGRESS_9 = 4 CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = CMAKE_PROGRESS_10 = 4
CMAKE_PROGRESS_11 = CMAKE_PROGRESS_11 =
CMAKE_PROGRESS_12 = 5 CMAKE_PROGRESS_12 = 5
CMAKE_PROGRESS_13 = CMAKE_PROGRESS_13 =
...@@ -17,8 +17,8 @@ CMAKE_PROGRESS_16 = ...@@ -17,8 +17,8 @@ CMAKE_PROGRESS_16 =
CMAKE_PROGRESS_17 = CMAKE_PROGRESS_17 =
CMAKE_PROGRESS_18 = 7 CMAKE_PROGRESS_18 = 7
CMAKE_PROGRESS_19 = CMAKE_PROGRESS_19 =
CMAKE_PROGRESS_20 = 8 CMAKE_PROGRESS_20 =
CMAKE_PROGRESS_21 = CMAKE_PROGRESS_21 = 8
CMAKE_PROGRESS_22 = CMAKE_PROGRESS_22 =
CMAKE_PROGRESS_23 = 9 CMAKE_PROGRESS_23 = 9
CMAKE_PROGRESS_24 = CMAKE_PROGRESS_24 =
...@@ -28,18 +28,18 @@ CMAKE_PROGRESS_27 = ...@@ -28,18 +28,18 @@ CMAKE_PROGRESS_27 =
CMAKE_PROGRESS_28 = CMAKE_PROGRESS_28 =
CMAKE_PROGRESS_29 = 11 CMAKE_PROGRESS_29 = 11
CMAKE_PROGRESS_30 = CMAKE_PROGRESS_30 =
CMAKE_PROGRESS_31 = 12 CMAKE_PROGRESS_31 =
CMAKE_PROGRESS_32 = CMAKE_PROGRESS_32 = 12
CMAKE_PROGRESS_33 = CMAKE_PROGRESS_33 =
CMAKE_PROGRESS_34 = 13 CMAKE_PROGRESS_34 =
CMAKE_PROGRESS_35 = CMAKE_PROGRESS_35 = 13
CMAKE_PROGRESS_36 = CMAKE_PROGRESS_36 =
CMAKE_PROGRESS_37 = 14 CMAKE_PROGRESS_37 = 14
CMAKE_PROGRESS_38 = CMAKE_PROGRESS_38 =
CMAKE_PROGRESS_39 = CMAKE_PROGRESS_39 =
CMAKE_PROGRESS_40 = 15 CMAKE_PROGRESS_40 = 15
CMAKE_PROGRESS_41 = CMAKE_PROGRESS_41 =
CMAKE_PROGRESS_42 = 16 CMAKE_PROGRESS_42 =
CMAKE_PROGRESS_43 = CMAKE_PROGRESS_43 = 16
CMAKE_PROGRESS_44 = CMAKE_PROGRESS_44 =
CMAKE_PROGRESS_1 = 17 CMAKE_PROGRESS_1 =
CMAKE_PROGRESS_2 = CMAKE_PROGRESS_2 = 17
CMAKE_PROGRESS_3 = CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = 18 CMAKE_PROGRESS_4 = 18
CMAKE_PROGRESS_5 = CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = 19 CMAKE_PROGRESS_7 = 19
CMAKE_PROGRESS_8 = CMAKE_PROGRESS_8 =
CMAKE_PROGRESS_9 = 20 CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = CMAKE_PROGRESS_10 = 20
CMAKE_PROGRESS_11 = CMAKE_PROGRESS_11 =
CMAKE_PROGRESS_12 = 21 CMAKE_PROGRESS_12 =
CMAKE_PROGRESS_13 = CMAKE_PROGRESS_13 = 21
CMAKE_PROGRESS_14 = CMAKE_PROGRESS_14 =
CMAKE_PROGRESS_15 = 22 CMAKE_PROGRESS_15 = 22
CMAKE_PROGRESS_16 = CMAKE_PROGRESS_16 =
CMAKE_PROGRESS_17 = CMAKE_PROGRESS_17 =
CMAKE_PROGRESS_18 = 23 CMAKE_PROGRESS_18 = 23
CMAKE_PROGRESS_19 = CMAKE_PROGRESS_19 =
CMAKE_PROGRESS_20 = 24 CMAKE_PROGRESS_20 =
CMAKE_PROGRESS_21 = CMAKE_PROGRESS_21 = 24
CMAKE_PROGRESS_22 = CMAKE_PROGRESS_22 =
CMAKE_PROGRESS_23 = 25 CMAKE_PROGRESS_23 =
CMAKE_PROGRESS_24 = CMAKE_PROGRESS_24 = 25
CMAKE_PROGRESS_25 = CMAKE_PROGRESS_25 =
CMAKE_PROGRESS_26 = 26 CMAKE_PROGRESS_26 =
CMAKE_PROGRESS_27 = CMAKE_PROGRESS_27 = 26
CMAKE_PROGRESS_28 = CMAKE_PROGRESS_28 =
CMAKE_PROGRESS_29 = 27 CMAKE_PROGRESS_29 = 27
CMAKE_PROGRESS_30 = CMAKE_PROGRESS_30 =
CMAKE_PROGRESS_31 = 28 CMAKE_PROGRESS_31 =
CMAKE_PROGRESS_32 = CMAKE_PROGRESS_32 = 28
CMAKE_PROGRESS_33 = CMAKE_PROGRESS_33 =
CMAKE_PROGRESS_34 = 29 CMAKE_PROGRESS_34 =
CMAKE_PROGRESS_35 = CMAKE_PROGRESS_35 = 29
CMAKE_PROGRESS_36 = CMAKE_PROGRESS_36 =
CMAKE_PROGRESS_37 = 30 CMAKE_PROGRESS_37 =
CMAKE_PROGRESS_38 = CMAKE_PROGRESS_38 = 30
CMAKE_PROGRESS_39 = CMAKE_PROGRESS_39 =
CMAKE_PROGRESS_40 = 31 CMAKE_PROGRESS_40 = 31
CMAKE_PROGRESS_41 = CMAKE_PROGRESS_41 =
CMAKE_PROGRESS_42 = 32 CMAKE_PROGRESS_42 =
CMAKE_PROGRESS_43 = CMAKE_PROGRESS_43 = 32
CMAKE_PROGRESS_44 = CMAKE_PROGRESS_44 =
...@@ -4,8 +4,8 @@ CMAKE_PROGRESS_3 = ...@@ -4,8 +4,8 @@ CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5 = 86 CMAKE_PROGRESS_5 = 86
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 = 87
CMAKE_PROGRESS_8 = 87 CMAKE_PROGRESS_8 =
CMAKE_PROGRESS_9 = CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = 88 CMAKE_PROGRESS_10 = 88
CMAKE_PROGRESS_11 = CMAKE_PROGRESS_11 =
......
CMAKE_PROGRESS_1 = CMAKE_PROGRESS_1 = 53
CMAKE_PROGRESS_2 = 53 CMAKE_PROGRESS_2 =
CMAKE_PROGRESS_3 = CMAKE_PROGRESS_3 =
CMAKE_PROGRESS_4 = CMAKE_PROGRESS_4 = 54
CMAKE_PROGRESS_5 = 54 CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6 = CMAKE_PROGRESS_6 =
CMAKE_PROGRESS_7 = CMAKE_PROGRESS_7 = 55
CMAKE_PROGRESS_8 = 55 CMAKE_PROGRESS_8 =
CMAKE_PROGRESS_9 = CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10 = 56 CMAKE_PROGRESS_10 = 56
CMAKE_PROGRESS_11 = CMAKE_PROGRESS_11 =
CMAKE_PROGRESS_12 = CMAKE_PROGRESS_12 = 57
CMAKE_PROGRESS_13 = 57 CMAKE_PROGRESS_13 =
CMAKE_PROGRESS_14 = CMAKE_PROGRESS_14 =
CMAKE_PROGRESS_15 = CMAKE_PROGRESS_15 = 58
CMAKE_PROGRESS_16 = 58 CMAKE_PROGRESS_16 =
CMAKE_PROGRESS_17 = CMAKE_PROGRESS_17 =
CMAKE_PROGRESS_18 = CMAKE_PROGRESS_18 = 59
CMAKE_PROGRESS_19 = 59 CMAKE_PROGRESS_19 =
CMAKE_PROGRESS_20 = CMAKE_PROGRESS_20 =
CMAKE_PROGRESS_21 = 60 CMAKE_PROGRESS_21 = 60
CMAKE_PROGRESS_22 = CMAKE_PROGRESS_22 =
CMAKE_PROGRESS_23 = CMAKE_PROGRESS_23 = 61
CMAKE_PROGRESS_24 = 61 CMAKE_PROGRESS_24 =
CMAKE_PROGRESS_25 = CMAKE_PROGRESS_25 =
CMAKE_PROGRESS_26 = CMAKE_PROGRESS_26 = 62
CMAKE_PROGRESS_27 = 62 CMAKE_PROGRESS_27 =
CMAKE_PROGRESS_28 = CMAKE_PROGRESS_28 =
CMAKE_PROGRESS_29 = CMAKE_PROGRESS_29 = 63
CMAKE_PROGRESS_30 = 63 CMAKE_PROGRESS_30 =
CMAKE_PROGRESS_31 = CMAKE_PROGRESS_31 =
CMAKE_PROGRESS_32 = 64 CMAKE_PROGRESS_32 = 64
CMAKE_PROGRESS_33 = CMAKE_PROGRESS_33 =
CMAKE_PROGRESS_34 = CMAKE_PROGRESS_34 =
CMAKE_PROGRESS_35 = 65 CMAKE_PROGRESS_35 = 65
CMAKE_PROGRESS_36 = CMAKE_PROGRESS_36 =
CMAKE_PROGRESS_37 = CMAKE_PROGRESS_37 = 66
CMAKE_PROGRESS_38 = 66 CMAKE_PROGRESS_38 =
CMAKE_PROGRESS_39 = CMAKE_PROGRESS_39 =
CMAKE_PROGRESS_40 = CMAKE_PROGRESS_40 = 67
CMAKE_PROGRESS_41 = 67 CMAKE_PROGRESS_41 =
CMAKE_PROGRESS_42 = CMAKE_PROGRESS_42 =
CMAKE_PROGRESS_43 = 68 CMAKE_PROGRESS_43 = 68
CMAKE_PROGRESS_44 = CMAKE_PROGRESS_44 =
CMAKE_PROGRESS_45 = CMAKE_PROGRESS_45 =
CMAKE_PROGRESS_46 = 69 CMAKE_PROGRESS_46 = 69
CMAKE_PROGRESS_47 = CMAKE_PROGRESS_47 =
CMAKE_PROGRESS_48 = CMAKE_PROGRESS_48 = 70
CMAKE_PROGRESS_49 = 70 CMAKE_PROGRESS_49 =
CMAKE_PROGRESS_50 = CMAKE_PROGRESS_50 =
CMAKE_PROGRESS_51 = CMAKE_PROGRESS_51 = 71
CMAKE_PROGRESS_52 = 71 CMAKE_PROGRESS_52 =
CMAKE_PROGRESS_53 = CMAKE_PROGRESS_53 =
CMAKE_PROGRESS_54 = 72 CMAKE_PROGRESS_54 = 72
CMAKE_PROGRESS_55 = CMAKE_PROGRESS_55 =
CMAKE_PROGRESS_56 = CMAKE_PROGRESS_56 =
CMAKE_PROGRESS_57 = 73 CMAKE_PROGRESS_57 = 73
CMAKE_PROGRESS_58 = CMAKE_PROGRESS_58 =
CMAKE_PROGRESS_59 = CMAKE_PROGRESS_59 = 74
CMAKE_PROGRESS_60 = 74 CMAKE_PROGRESS_60 =
CMAKE_PROGRESS_61 = CMAKE_PROGRESS_61 =
CMAKE_PROGRESS_62 = CMAKE_PROGRESS_62 = 75
CMAKE_PROGRESS_63 = 75 CMAKE_PROGRESS_63 =
CMAKE_PROGRESS_64 = CMAKE_PROGRESS_64 =
CMAKE_PROGRESS_65 = 76 CMAKE_PROGRESS_65 = 76
CMAKE_PROGRESS_66 = CMAKE_PROGRESS_66 =
...@@ -70,7 +70,7 @@ CMAKE_PROGRESS_69 = ...@@ -70,7 +70,7 @@ CMAKE_PROGRESS_69 =
CMAKE_PROGRESS_70 = CMAKE_PROGRESS_70 =
CMAKE_PROGRESS_71 = 78 CMAKE_PROGRESS_71 = 78
CMAKE_PROGRESS_72 = CMAKE_PROGRESS_72 =
CMAKE_PROGRESS_73 = CMAKE_PROGRESS_73 = 79
CMAKE_PROGRESS_74 = 79 CMAKE_PROGRESS_74 =
CMAKE_PROGRESS_75 = CMAKE_PROGRESS_75 =
...@@ -22,6 +22,11 @@ const device_didrive device_didrive_control_config_t[]={ ...@@ -22,6 +22,11 @@ const device_didrive device_didrive_control_config_t[]={
.device_id = DEVICE_TANK0202, .device_id = DEVICE_TANK0202,
.device_didrive_control = tank0202_change .device_didrive_control = tank0202_change
}, },
{
.device_id = DEVICE_TANK0203,
.device_didrive_control = tank0203_change
},
{ {
.device_id = DEVICE_PAO_PTZ0401, .device_id = DEVICE_PAO_PTZ0401,
.device_didrive_control = PTZ_pwm_change .device_didrive_control = PTZ_pwm_change
...@@ -37,31 +42,44 @@ const device_abnormal_close_t devcontrol_config_t[]= { ...@@ -37,31 +42,44 @@ const device_abnormal_close_t devcontrol_config_t[]= {
.gpio_pin_pulled=pin_all_default, .gpio_pin_pulled=pin_all_default,
.gpio_pwm_pulled=pwm_all_default .gpio_pwm_pulled=pwm_all_default
}, },
{ {
.device_id = DEVICE_CAR0102, .device_id = DEVICE_CAR0102,
.device_abnormal_stop = car0102_speed_stop, .device_abnormal_stop = car0102_speed_stop,
.gpio_pin_pulled=pin_all_default, .gpio_pin_pulled=pin_all_default,
.gpio_pwm_pulled=pwm_all_default .gpio_pwm_pulled=pwm_all_default
}, },
{ {
.device_id = DEVICE_CAR0103, .device_id = DEVICE_CAR0103,
.device_abnormal_stop = car0103_middle, .device_abnormal_stop = car0103_middle,
.gpio_pin_pulled=pin_all_default, .gpio_pin_pulled=pin_all_default,
.gpio_pwm_pulled=pwm_all_default .gpio_pwm_pulled=pwm_all_default
}, },
{ {
.device_id = DEVICE_CAR0104, .device_id = DEVICE_CAR0104,
.device_abnormal_stop = car0104_stop, .device_abnormal_stop = car0104_stop,
.gpio_pin_pulled=pin_all_default, .gpio_pin_pulled=pin_all_default,
.gpio_pwm_pulled=pwm_all_default .gpio_pwm_pulled=pwm_all_default
}, },
{ {
.device_id = DEVICE_TANK0202, .device_id = DEVICE_TANK0202,
.device_abnormal_stop = tank0202_middle, .device_abnormal_stop = tank0202_middle,
.device_close = tank0202_thread_close, .device_close = tank_thread_close,
.gpio_pin_pulled=pin_all_default, .gpio_pin_pulled=pin_all_default,
.gpio_pwm_pulled=pwm_all_default .gpio_pwm_pulled=pwm_all_default
}, },
{
.device_id = DEVICE_TANK0203,
.device_abnormal_stop = tank0203_middle,
.device_close = tank_thread_close,
.gpio_pin_pulled=pin_all_default,
.gpio_pwm_pulled=pwm_all_default
},
{ {
.device_id = DEVICE_PAO_PTZ0401, .device_id = DEVICE_PAO_PTZ0401,
.device_abnormal_stop = PTZ_pwm_init, .device_abnormal_stop = PTZ_pwm_init,
......
#include "common.h"
#include "gpio_init.h"
#include "tank0202_control.h"
int g_modecount_tank0202=0;
void tank0202_middle() {
pwmWrite(PWM_PIN_SPEED,75);
pwmWrite(PWM_PIN_CHANGE,75);
}
void mode_lift_flont(unsigned char gval) {
if (gval < 50) {
pwmWrite(PWM_PIN_SPEED, 75);
} else if (gval <= 55) {
pwmWrite(PWM_PIN_SPEED, 78);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_SPEED, 79);
} else if (gval <= 65) {
pwmWrite(PWM_PIN_SPEED, 80);
} else if (gval <= 70) {
pwmWrite(PWM_PIN_SPEED, 81);
} else if (gval <= 75) {
pwmWrite(PWM_PIN_SPEED, 82);
} else if (gval <= 90) {
pwmWrite(PWM_PIN_SPEED, 83);
} else if (gval <= 100) {
pwmWrite(PWM_PIN_SPEED, 84);
} else if (gval <= 110) {
pwmWrite(PWM_PIN_SPEED, 85);
} else if (gval <= 120) {
pwmWrite(PWM_PIN_SPEED, 86);
} else if (gval <= 130) {
pwmWrite(PWM_PIN_SPEED, 87);
} else if (gval <= 140) {
pwmWrite(PWM_PIN_SPEED, 88);
} else if (gval <= 150) {
pwmWrite(PWM_PIN_SPEED, 89);
} else if (gval <= 160) {
pwmWrite(PWM_PIN_SPEED, 90);
} else if (gval <= 170) {
pwmWrite(PWM_PIN_SPEED, 91);
} else if (gval <= 180) {
pwmWrite(PWM_PIN_SPEED, 92);
} else if (gval <= 190) {
pwmWrite(PWM_PIN_SPEED, 93);
} else if (gval <= 200) {
pwmWrite(PWM_PIN_SPEED, 94);
}
}
void mode_lift_back(unsigned char gval) {
if (gval < 50) {
pwmWrite(PWM_PIN_SPEED, 75);
} else if (gval <= 55) {
pwmWrite(PWM_PIN_SPEED, 72);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_SPEED, 71);
} else if (gval <= 65) {
pwmWrite(PWM_PIN_SPEED, 70);
} else if (gval <= 70) {
pwmWrite(PWM_PIN_SPEED, 69);
} else if (gval <= 75) {
pwmWrite(PWM_PIN_SPEED, 68);
} else if (gval <= 90) {
pwmWrite(PWM_PIN_SPEED, 67);
} else if (gval <= 100) {
pwmWrite(PWM_PIN_SPEED, 66);
} else if (gval <= 110) {
pwmWrite(PWM_PIN_SPEED, 65);
} else if (gval <= 120) {
pwmWrite(PWM_PIN_SPEED, 64);
} else if (gval <= 130) {
pwmWrite(PWM_PIN_SPEED, 63);
} else if (gval <= 140) {
pwmWrite(PWM_PIN_SPEED, 62);
} else if (gval <= 150) {
pwmWrite(PWM_PIN_SPEED, 61);
} else if (gval <= 160) {
pwmWrite(PWM_PIN_SPEED, 60);
} else if (gval <= 170) {
pwmWrite(PWM_PIN_SPEED, 59);
} else if (gval <= 180) {
pwmWrite(PWM_PIN_SPEED, 58);
} else if (gval <= 190) {
pwmWrite(PWM_PIN_SPEED, 57);
} else if (gval <= 200) {
pwmWrite(PWM_PIN_SPEED, 56);
}
}
void mode_right_flont(unsigned char gval) {
if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75);
} else if (gval <= 55) {
pwmWrite(PWM_PIN_CHANGE, 78);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_CHANGE, 79);
} else if (gval <= 65) {
pwmWrite(PWM_PIN_CHANGE, 80);
} else if (gval <= 70) {
pwmWrite(PWM_PIN_CHANGE, 81);
} else if (gval <= 75) {
pwmWrite(PWM_PIN_CHANGE, 82);
} else if (gval <= 90) {
pwmWrite(PWM_PIN_CHANGE, 83);
} else if (gval <= 100) {
pwmWrite(PWM_PIN_CHANGE, 84);
} else if (gval <= 110) {
pwmWrite(PWM_PIN_CHANGE, 85);
} else if (gval <= 120) {
pwmWrite(PWM_PIN_CHANGE, 86);
} else if (gval <= 130) {
pwmWrite(PWM_PIN_CHANGE, 87);
} else if (gval <= 140) {
pwmWrite(PWM_PIN_CHANGE, 88);
} else if (gval <= 150) {
pwmWrite(PWM_PIN_CHANGE, 89);
} else if (gval <= 160) {
pwmWrite(PWM_PIN_CHANGE, 90);
} else if (gval <= 170) {
pwmWrite(PWM_PIN_CHANGE, 91);
} else if (gval <= 180) {
pwmWrite(PWM_PIN_CHANGE, 92);
} else if (gval <= 190) {
pwmWrite(PWM_PIN_CHANGE, 93);
} else if (gval <= 200) {
pwmWrite(PWM_PIN_CHANGE, 94);
}
}
void mode_right_back(unsigned char gval) {
if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75);
} else if (gval <= 55) {
pwmWrite(PWM_PIN_CHANGE, 71);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 65) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 70) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 75) {
pwmWrite(PWM_PIN_CHANGE, 69);
} else if (gval <= 90) {
pwmWrite(PWM_PIN_CHANGE, 68);
} else if (gval <= 100) {
pwmWrite(PWM_PIN_CHANGE, 68);
} else if (gval <= 110) {
pwmWrite(PWM_PIN_CHANGE, 66);
} else if (gval <= 120) {
pwmWrite(PWM_PIN_CHANGE, 65);
} else if (gval <= 130) {
pwmWrite(PWM_PIN_CHANGE, 64);
} else if (gval <= 140) {
pwmWrite(PWM_PIN_CHANGE, 62);
} else if (gval <= 150) {
pwmWrite(PWM_PIN_CHANGE, 60);
} else if (gval <= 160) {
pwmWrite(PWM_PIN_CHANGE, 59);
} else if (gval <= 170) {
pwmWrite(PWM_PIN_CHANGE, 58);
} else if (gval <= 180) {
pwmWrite(PWM_PIN_CHANGE, 57);
} else if (gval <= 190) {
pwmWrite(PWM_PIN_CHANGE, 56);
} else if (gval <= 200) {
pwmWrite(PWM_PIN_CHANGE, 55);
}
}
void tank0202_change(unsigned char *buf) {
unsigned char mode = buf[1];
unsigned char val = buf[2];
if(mode == 1 ) {
//mode_lift_flont(val);
mode_right_flont(val);
g_modecount_tank0202=0;
}else if(mode == 2 ) {
//mode_lift_back(val);
mode_right_back(val);
g_modecount_tank0202=1;
}
if((mode == 1||mode ==2)&&val == 0) g_modecount_tank0202=0;
if(mode == 3) {
if(g_modecount_tank0202 == 0) mode_lift_back(val+20);
if(g_modecount_tank0202 == 1) mode_lift_flont(val+20);
}else if(mode == 4) {
if(g_modecount_tank0202 == 0) mode_lift_flont(val+20);
if(g_modecount_tank0202 == 1) mode_lift_back(val+20);
}
}
...@@ -5,12 +5,8 @@ ...@@ -5,12 +5,8 @@
void tank0202_middle(); void tank0202_middle();
void tank_shot_back_stop_task_end();
void tank0202_change(unsigned char *buf); void tank0202_change(unsigned char *buf);
int tank_shot_back_stop(int pin,int val);
/*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/ /*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/
void tank0202_thread_close(); void tank0202_thread_close();
#endif #endif
\ No newline at end of file
#include "common.h" #include "common.h"
#include "gpio_init.h" #include "gpio_init.h"
#include "pthrpoll.h" #include "pthrpoll.h"
#include "tank02002_control.h" #include "tank0203_control.h"
int g_modecount_tank0202=0; int g_modecount_tank0203=0;
void tank0202_middle() { void tank0203_middle() {
pwmWrite(PWM_PIN_SPEED,75); pwmWrite(PWM_PIN_SPEED,75);
pwmWrite(PWM_PIN_CHANGE,75); pwmWrite(PWM_PIN_CHANGE,75);
} }
void mode_lift_flont(unsigned char gval) { void tank0203_mode_lift_flont(unsigned char gval) {
if (gval < 50) { if (gval < 50) {
pwmWrite(PWM_PIN_SPEED, 75); pwmWrite(PWM_PIN_SPEED, 75);
} else if (gval <= 55) { } else if (gval <= 55) {
...@@ -50,7 +50,7 @@ void mode_lift_flont(unsigned char gval) { ...@@ -50,7 +50,7 @@ void mode_lift_flont(unsigned char gval) {
} }
} }
void mode_lift_back(unsigned char gval) { void tank0203_mode_lift_back(unsigned char gval) {
if (gval < 50) { if (gval < 50) {
pwmWrite(PWM_PIN_SPEED, 75); pwmWrite(PWM_PIN_SPEED, 75);
} else if (gval <= 55) { } else if (gval <= 55) {
...@@ -90,7 +90,7 @@ void mode_lift_back(unsigned char gval) { ...@@ -90,7 +90,7 @@ void mode_lift_back(unsigned char gval) {
} }
} }
void mode_right_flont(unsigned char gval) { void tank0203_mode_right_flont(unsigned char gval) {
if (gval < 50) { if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75); pwmWrite(PWM_PIN_CHANGE, 75);
} else if (gval <= 55) { } else if (gval <= 55) {
...@@ -130,7 +130,7 @@ void mode_right_flont(unsigned char gval) { ...@@ -130,7 +130,7 @@ void mode_right_flont(unsigned char gval) {
} }
} }
void mode_right_back(unsigned char gval) { void tank0203_mode_right_back(unsigned char gval) {
if (gval < 50) { if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75); pwmWrite(PWM_PIN_CHANGE, 75);
} else if (gval <= 55) { } else if (gval <= 55) {
...@@ -170,103 +170,29 @@ void mode_right_back(unsigned char gval) { ...@@ -170,103 +170,29 @@ void mode_right_back(unsigned char gval) {
} }
} }
void tank0202_change(unsigned char *buf) { void tank0203_change(unsigned char *buf) {
unsigned char mode = buf[1]; unsigned char mode = buf[1];
unsigned char val = buf[2]; unsigned char val = buf[2];
if(mode == 1 ) { if(mode == 1 ) {
//mode_lift_flont(val); //tank0203_mode_lift_flont(val);
mode_right_flont(val); tank0203_mode_right_flont(val);
g_modecount_tank0202=0; g_modecount_tank0203=0;
}else if(mode == 2 ) { }else if(mode == 2 ) {
//mode_lift_back(val); //tank0203_mode_lift_back(val);
mode_right_back(val); tank0203_mode_right_back(val);
g_modecount_tank0202=1; g_modecount_tank0203=1;
} }
if((mode == 1||mode ==2)&&val == 0) g_modecount_tank0202=0; if((mode == 1||mode ==2)&&val == 0) g_modecount_tank0203=0;
if(mode == 3) { if(mode == 3) {
if(g_modecount_tank0202 == 0) mode_lift_back(val+25); if(g_modecount_tank0203 == 0) tank0203_mode_lift_back(val+15);
if(g_modecount_tank0202 == 1) mode_lift_flont(val+25); if(g_modecount_tank0203 == 1) tank0203_mode_lift_flont(val+15);
}else if(mode == 4) { }else if(mode == 4) {
if(g_modecount_tank0202 == 0) mode_lift_flont(val+25); if(g_modecount_tank0203 == 0) tank0203_mode_lift_flont(val+15);
if(g_modecount_tank0202 == 1) mode_lift_back(val+25); if(g_modecount_tank0203 == 1) tank0203_mode_lift_back(val+15);
} }
} }
long long shot_device_time_start =0 ;
long long shot_device_time_end = 0;
// 函数功能:获取当前精确到毫秒的时间戳
// 返回值:当前时间的毫秒数
long long get_current_time_millis() {
struct timeval tv;
// 获取当前时间,存储在tv结构体中,第二个参数一般传NULL
if (gettimeofday(&tv, NULL)!= 0) {
perror("gettimeofday error");
return -1;
}
// 秒数部分转换为毫秒(乘以1000),微秒数部分转换为毫秒(除以1000),然后相加
return (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
void tank_shot_back_stop_task_function(void *arg) {//多线程处理坦克发射后退线程池
while(1){
long long interval=shot_device_time_start-shot_device_time_end;
if(g_device_delay_count>10&&g_device_delay_count<=25) mode_right_back(0);
if(interval>100){
if(g_device_delay_count <= 10) {
mode_right_back(80);
my_zlog_debug("操作耗时: %lld 毫秒", interval);
}
}
}
free(arg);
}
ThreadPool_t *pool_tank;
void tank_shot_back_stop_task_end(){
thread_pool_destroy(pool_tank);
}
void tank_shot_pthrpoll_task_init(){
int *arg = malloc(sizeof(int));
*arg = 1;
pool_tank=thread_pool_init(1,1);
thread_pool_add_task(pool_tank, tank_shot_back_stop_task_function, &arg);
my_zlog_debug("线程池打开");
}
int tank_shot_back_stop(int pin,int val){
static int shot_count=0;
shot_device_time_start=get_current_time_millis();
if(pin !=27){
my_zlog_debug("非27引脚");
return 1;
}
if(val == 0) {
mode_right_back(0);
shot_count=2;
}
if(val != 0) {
if(shot_count == 0){
tank_shot_pthrpoll_task_init();
shot_count=1;
}
shot_count=1;
if(shot_count == 1){
g_device_delay_count=0;
}
}
shot_device_time_end=get_current_time_millis();
}
/*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/
void tank0202_thread_close(){
thread_pool_destroy(pool_tank);
}
\ No newline at end of file
#ifndef TANK0203_CONTROL_H__
#define TANK0203_CONTROL_H__
void tank0203_middle();
void tank0203_change(unsigned char *buf);
int tank_shot_back_stop(int pin,int val);
/*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/
void tank0203_thread_close();
#endif
\ No newline at end of file
#include "tank_common.h"
#include "devcontrol_common.h"
#include "gpio_init.h"
#include "pthrpoll.h"
_Thread_local const tank_common_back *g_tank_common_config_t = NULL;
long long shot_device_time_start =0 ;
long long shot_device_time_end = 0;
int tank_shot_back_stop(int pin,int val);
void tank_shot_back(unsigned char gval) {
if (gval < 50) {
pwmWrite(PWM_PIN_CHANGE, 75);
} else if (gval <= 55) {
pwmWrite(PWM_PIN_CHANGE, 71);
} else if (gval <= 60) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 65) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 70) {
pwmWrite(PWM_PIN_CHANGE, 70);
} else if (gval <= 75) {
pwmWrite(PWM_PIN_CHANGE, 69);
} else if (gval <= 90) {
pwmWrite(PWM_PIN_CHANGE, 68);
} else if (gval <= 100) {
pwmWrite(PWM_PIN_CHANGE, 68);
} else if (gval <= 110) {
pwmWrite(PWM_PIN_CHANGE, 66);
} else if (gval <= 120) {
pwmWrite(PWM_PIN_CHANGE, 65);
} else if (gval <= 130) {
pwmWrite(PWM_PIN_CHANGE, 64);
} else if (gval <= 140) {
pwmWrite(PWM_PIN_CHANGE, 62);
} else if (gval <= 150) {
pwmWrite(PWM_PIN_CHANGE, 60);
} else if (gval <= 160) {
pwmWrite(PWM_PIN_CHANGE, 59);
} else if (gval <= 170) {
pwmWrite(PWM_PIN_CHANGE, 58);
} else if (gval <= 180) {
pwmWrite(PWM_PIN_CHANGE, 57);
} else if (gval <= 190) {
pwmWrite(PWM_PIN_CHANGE, 56);
} else if (gval <= 200) {
pwmWrite(PWM_PIN_CHANGE, 55);
}
}
const tank_common_back tank_common_config_t[]={
{
.device_id = DEVICE_TANK0202,
.back_time=15,//后退多少ms
.back_interval_back=200, //间隔多少ms才能再次使用
.shot_back_speed=80,
.shot_back=tank_shot_back_stop
},
{
.device_id = DEVICE_TANK0203,
.back_time=15,//后退多少ms
.back_interval_back=200, //间隔多少ms才能再次使用
.shot_back_speed=80,
.shot_back=tank_shot_back_stop
},
{ .device_id = -1 }
};
void tank_shot_back_stop_task_function(void *arg) {//多线程处理坦克发射后退线程池
while(1){
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))
tank_shot_back(0);
if(interval > g_tank_common_config_t->back_interval_back){
if(g_device_delay_count <= g_tank_common_config_t->back_time) {
tank_shot_back(g_tank_common_config_t->shot_back_speed);
my_zlog_debug("操作耗时: %lld 毫秒", interval);
}
}
}
free(arg);
}
ThreadPool_t *pool_tank_t;
void tank_shot_pthrpoll_task_init(){
int *arg = malloc(sizeof(int));
*arg = 1;
pool_tank_t=thread_pool_init(1,1);
thread_pool_add_task(pool_tank_t, tank_shot_back_stop_task_function, &arg);
my_zlog_debug("线程池打开");
}
int tank_shot_back_stop(int pin,int val){
static int shot_count=0;
shot_device_time_start=get_current_time_millis();
if(pin !=27){
my_zlog_debug("非27引脚");
return 1;
}
if(val == 0) {
tank_shot_back(0);
shot_count=2;
}
if(val != 0) {
if(shot_count == 0){
tank_shot_pthrpoll_task_init();
shot_count=1;
}
shot_count=1;
if(shot_count == 1){
g_device_delay_count=0;
}
}
shot_device_time_end=get_current_time_millis();
}
/*销毁坦克使用的线程池,让其正常销毁,只有在tank0202设备号下才有用*/
void tank_thread_close(){
thread_pool_destroy(pool_tank_t);
}
void tank_shot_stop_control(int device_id,int pin,int val) {
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++) {
if(tank_common_config_t[i].device_id == device_id) {
g_tank_common_config_t = &tank_common_config_t[i];
break;
}
}
}
if(!g_tank_common_config_t) {
my_zlog_error("Error: Device stop ID %d not found!\n", device_id);
return;
}
g_tank_common_config_t->shot_back(pin,val);
}
\ No newline at end of file
#ifndef TANK_COMMON_H
#define TANK_COMMON_H
#include "common.h"
typedef struct {
int device_id; // 设备ID (101, 102等)
int back_time;
int back_interval_back;
int shot_back_speed;
int(*shot_back)(int pin,int val);
} tank_common_back;
void tank_shot_stop_control(int device_id,int pin,int val);
void tank_thread_close();
#endif
\ No newline at end of file
...@@ -58,7 +58,15 @@ const deviceconfig_t device_configs[] = { ...@@ -58,7 +58,15 @@ const deviceconfig_t device_configs[] = {
.device_control_stop = tank0202_middle,/* 补充速度控制函数 */ .device_control_stop = tank0202_middle,/* 补充速度控制函数 */
.emergency_code = 202 .emergency_code = 202
}, },
{
.device_id = DEVICE_TANK0203,
.device_name = "tank0203",
.gpio_pins = {6, 16, 20, 22, 23,-1},/* 补充GPIO引脚 */
.gpio_pwms = {5 , 7 ,24,26, 27,-1},
.device_pwm_init = physics_pwm_init,
.device_control_stop = tank0203_middle,/* 补充速度控制函数 */
.emergency_code = 203
},
{ {
.device_id = DEVICE_PAO_PTZ0401, .device_id = DEVICE_PAO_PTZ0401,
.device_name = "ptz0401", .device_name = "ptz0401",
......
...@@ -67,14 +67,18 @@ void pwm_value(int pin,int value) { //软件陪我们控制调速 ...@@ -67,14 +67,18 @@ void pwm_value(int pin,int value) { //软件陪我们控制调速
if(value==1) { if(value==1) {
if(pin == 27){ if(pin == 27){
if(g_device_type != DEVICE_TANK0202 ){ if(g_device_type == DEVICE_TANK0202) softPwmWrite(pin, 50);
else if(g_device_type == DEVICE_TANK0203) softPwmWrite(pin, 50);
else {
softPwmWrite(pin, shot_speed); softPwmWrite(pin, shot_speed);
my_zlog_debug("pin:%d,%d",pin,shot_speed); my_zlog_debug("pin:%d,%d",pin,shot_speed);
} }
if(g_device_type == DEVICE_TANK0202) softPwmWrite(pin, 40);
} else { } else {
if(g_device_type == DEVICE_TANK0202) softPwmWrite(pin, 30); if(g_device_type == DEVICE_TANK0202) softPwmWrite(pin, 35);
if(g_device_type != DEVICE_TANK0202 )softPwmWrite(pin, shot_speed); if(g_device_type == DEVICE_TANK0203) softPwmWrite(pin, 35);
else{
softPwmWrite(pin, shot_speed);
}
} }
......
...@@ -7,9 +7,20 @@ ...@@ -7,9 +7,20 @@
#include "car0103_control.h" #include "car0103_control.h"
#include "car0104_control.h" #include "car0104_control.h"
#include "ptz0401_control.h" #include "ptz0401_control.h"
#include "tank02002_control.h" #include "tank0202_control.h"
#include "tank0203_control.h"
#include "tank_common.h"
#include "common.h" #include "common.h"
#define DEVICE_CAR0101 101
#define DEVICE_CAR0102 102
#define DEVICE_CAR0103 103
#define DEVICE_CAR0104 104
#define DEVICE_TANK0201 201
#define DEVICE_TANK0202 202
#define DEVICE_TANK0203 203
#define DEVICE_PAO_PTZ0401 401
typedef struct { typedef struct {
int device_id; // 设备ID (101, 102等) int device_id; // 设备ID (101, 102等)
void (*device_abnormal_stop)(void); // 车停止 void (*device_abnormal_stop)(void); // 车停止
...@@ -23,13 +34,7 @@ typedef struct { ...@@ -23,13 +34,7 @@ typedef struct {
void (*device_didrive_control)(unsigned char *valt); // PWM初始化函数指针 void (*device_didrive_control)(unsigned char *valt); // PWM初始化函数指针
} device_didrive; } device_didrive;
#define DEVICE_CAR0101 101
#define DEVICE_CAR0102 102
#define DEVICE_CAR0103 103
#define DEVICE_CAR0104 104
#define DEVICE_TANK0201 201
#define DEVICE_TANK0202 202
#define DEVICE_PAO_PTZ0401 401
void device_stop(int device_id); void device_stop(int device_id);
......
...@@ -22,3 +22,16 @@ void delay_us(int usec) { ...@@ -22,3 +22,16 @@ void delay_us(int usec) {
ts.tv_nsec = usec*1000; // 1毫秒 = 1000000纳秒 ts.tv_nsec = usec*1000; // 1毫秒 = 1000000纳秒
nanosleep(&ts,NULL); nanosleep(&ts,NULL);
} }
// 函数功能:获取当前精确到毫秒的时间戳
// 返回值:当前时间的毫秒数
long long get_current_time_millis() {
struct timeval tv;
// 获取当前时间,存储在tv结构体中,第二个参数一般传NULL
if (gettimeofday(&tv, NULL)!= 0) {
perror("gettimeofday error");
return -1;
}
// 秒数部分转换为毫秒(乘以1000),微秒数部分转换为毫秒(除以1000),然后相加
return (long long)tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
\ No newline at end of file
...@@ -7,4 +7,6 @@ void delay_s(int sec); ...@@ -7,4 +7,6 @@ void delay_s(int sec);
void delay_us(int usec); void delay_us(int usec);
long long get_current_time_millis();
#endif #endif
\ No newline at end of file
...@@ -105,13 +105,14 @@ void angle_mqtt_send() { ...@@ -105,13 +105,14 @@ void angle_mqtt_send() {
} }
//心跳格式,每5s一次心跳 //心跳格式,每5s一次心跳
void mqtt_wirte(){ void mqtt_beat_wirte(){
if( g_heartbeat_count >= 30) { if( g_heartbeat_count >= 30) {
heartbeat_send(); heartbeat_send();
g_heartbeat_count=0; g_heartbeat_count=0;
} }
if( g_device_type == 202) angle_mqtt_send(); if( g_device_type == DEVICE_TANK0202) angle_mqtt_send();
if( g_device_type == DEVICE_TANK0203) angle_mqtt_send();
} }
...@@ -170,7 +171,7 @@ void message_4(cJSON *body){//message 为4时候 ...@@ -170,7 +171,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]);
if(g_device_type == DEVICE_TANK0202 ) tank_shot_back_stop(g_valt[1],g_valt[2]); tank_shot_stop_control(g_device_type,g_valt[1],g_valt[2]);
} }
//当接收到2时候验证 //当接收到2时候验证
......
...@@ -8,7 +8,7 @@ extern int g_heartbeat_count; ...@@ -8,7 +8,7 @@ extern int g_heartbeat_count;
extern int g_devcontrol_exit_count; extern int g_devcontrol_exit_count;
void mqtt_wirte(); void mqtt_beat_wirte();
int device_message_receive(cJSON *json); int device_message_receive(cJSON *json);
#endif #endif
\ No newline at end of file
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