Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
car-controlserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenzhongjian
car-controlserver
Commits
c08ca4d0
Commit
c08ca4d0
authored
Dec 10, 2025
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化了坦克射击,为检测射击,加入了0207水弹坦克
parent
5c540ef9
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
435 additions
and
60 deletions
+435
-60
device_identity.c
app/device_identity/device_identity.c
+5
-1
device_identity.h
app/device_identity/device_identity.h
+1
-0
Makefile
build/Makefile
+27
-0
main
build/main
+0
-0
progress.make
...squitto/client/CMakeFiles/mosquitto_pub.dir/progress.make
+1
-1
progress.marks
build/third_party/mosquitto/client/CMakeFiles/progress.marks
+1
-1
progress.make
...y/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
+4
-4
progress.make
...itto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
+8
-8
progress.marks
...d/third_party/mosquitto/plugins/CMakeFiles/progress.marks
+1
-1
progress.make
...y/CMakeFiles/mosquitto_dynamic_security.dir/progress.make
+2
-2
progress.make
...akeFiles/mosquitto_payload_modification.dir/progress.make
+1
-1
progress.marks
...to/plugins/payload-modification/CMakeFiles/progress.marks
+1
-1
progress.make
...arty/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
+14
-14
devcontrol_common.c
drivers/devicecontrol/devcontrol_common.c
+26
-4
devcontrol_common.h
drivers/devicecontrol/devcontrol_common.h
+2
-0
tank0207_control.c
drivers/devicecontrol/tank0207_control.c
+180
-0
tank0207_control.h
drivers/devicecontrol/tank0207_control.h
+9
-0
tank_common.c
drivers/devicecontrol/tank_common.c
+43
-9
tank_common.h
drivers/devicecontrol/tank_common.h
+10
-1
device_init.c
drivers/gpio/device_init.c
+10
-0
gpio_control.c
drivers/gpio/gpio_control.c
+77
-10
gpio_init.c
drivers/gpio/gpio_init.c
+9
-0
gpio_init.h
drivers/gpio/gpio_init.h
+2
-0
http_config_mqtt.c
modules/http/http_config_mqtt.c
+1
-1
mqtt_verify.c
modules/mqtt/mqtt_verify.c
+0
-1
No files found.
app/device_identity/device_identity.c
View file @
c08ca4d0
...
...
@@ -95,7 +95,8 @@ int hash_insert_init(HashTable_t *HashTable_t) {
insert
(
HashTable_t
,
"0202"
,
TANK_0202
);
insert
(
HashTable_t
,
"0203"
,
TANK_0203
);
insert
(
HashTable_t
,
"0204"
,
TANK_0204
);
insert
(
HashTable_t
,
"0206"
,
TANK_0206
);
insert
(
HashTable_t
,
"0206"
,
TANK_0206
);
insert
(
HashTable_t
,
"0207"
,
TANK_0207
);
insert
(
HashTable_t
,
"0301"
,
SHIP_0301
);
insert
(
HashTable_t
,
"0401"
,
PAO_0401
);
insert
(
HashTable_t
,
"0403"
,
PGGPS_0403
);
...
...
@@ -127,6 +128,9 @@ int device_judg(CodeEnum_t code,char *sub_str) {
}
else
if
(
code
==
TANK_0206
)
{
device_init
(
DEVICE_TANK0206
);
my_zlog_info
(
"使用水坦克,型号%s"
,
sub_str
);
}
else
if
(
code
==
TANK_0207
)
{
device_init
(
DEVICE_TANK0207
);
my_zlog_info
(
"使用射水弹坦克,型号%s"
,
sub_str
);
}
else
if
(
code
==
SHIP_0301
)
{
device_init
(
DEVICE_SHIP0301
);
my_zlog_info
(
"使用34号船,型号%s"
,
sub_str
);
...
...
app/device_identity/device_identity.h
View file @
c08ca4d0
...
...
@@ -17,6 +17,7 @@ typedef enum {
TANK_0203
,
TANK_0204
,
TANK_0206
,
TANK_0207
,
SHIP_0301
,
PAO_0401
,
PGGPS_0403
,
...
...
build/Makefile
View file @
c08ca4d0
...
...
@@ -809,6 +809,30 @@ drivers/devicecontrol/tank0206_control.c.s:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0206_control.c.s
.PHONY
:
drivers/devicecontrol/tank0206_control.c.s
drivers/devicecontrol/tank0207_control.o
:
drivers/devicecontrol/tank0207_control.c.o
.PHONY
:
drivers/devicecontrol/tank0207_control.o
# target to build an object file
drivers/devicecontrol/tank0207_control.c.o
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0207_control.c.o
.PHONY
:
drivers/devicecontrol/tank0207_control.c.o
drivers/devicecontrol/tank0207_control.i
:
drivers/devicecontrol/tank0207_control.c.i
.PHONY
:
drivers/devicecontrol/tank0207_control.i
# target to preprocess a source file
drivers/devicecontrol/tank0207_control.c.i
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0207_control.c.i
.PHONY
:
drivers/devicecontrol/tank0207_control.c.i
drivers/devicecontrol/tank0207_control.s
:
drivers/devicecontrol/tank0207_control.c.s
.PHONY
:
drivers/devicecontrol/tank0207_control.s
# target to generate assembly for a file
drivers/devicecontrol/tank0207_control.c.s
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/tank0207_control.c.s
.PHONY
:
drivers/devicecontrol/tank0207_control.c.s
drivers/devicecontrol/tank_common.o
:
drivers/devicecontrol/tank_common.c.o
.PHONY
:
drivers/devicecontrol/tank_common.o
...
...
@@ -1997,6 +2021,9 @@ help:
@
echo
"... drivers/devicecontrol/tank0206_control.o"
@
echo
"... drivers/devicecontrol/tank0206_control.i"
@
echo
"... drivers/devicecontrol/tank0206_control.s"
@
echo
"... drivers/devicecontrol/tank0207_control.o"
@
echo
"... drivers/devicecontrol/tank0207_control.i"
@
echo
"... drivers/devicecontrol/tank0207_control.s"
@
echo
"... drivers/devicecontrol/tank_common.o"
@
echo
"... drivers/devicecontrol/tank_common.i"
@
echo
"... drivers/devicecontrol/tank_common.s"
...
...
build/main
View file @
c08ca4d0
No preview for this file type
build/third_party/mosquitto/client/CMakeFiles/mosquitto_pub.dir/progress.make
View file @
c08ca4d0
CMAKE_PROGRESS_1
=
93
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
94
CMAKE_PROGRESS_4
=
...
...
build/third_party/mosquitto/client/CMakeFiles/progress.marks
View file @
c08ca4d0
2
1
2
0
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
View file @
c08ca4d0
...
...
@@ -17,8 +17,8 @@ CMAKE_PROGRESS_16 =
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_18
=
6
CMAKE_PROGRESS_19
=
CMAKE_PROGRESS_20
=
7
CMAKE_PROGRESS_21
=
CMAKE_PROGRESS_20
=
CMAKE_PROGRESS_21
=
7
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_23
=
8
CMAKE_PROGRESS_24
=
...
...
@@ -37,8 +37,8 @@ CMAKE_PROGRESS_36 =
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_38
=
13
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_40
=
14
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_41
=
14
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_43
=
15
CMAKE_PROGRESS_44
=
...
...
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
View file @
c08ca4d0
...
...
@@ -10,11 +10,11 @@ CMAKE_PROGRESS_9 =
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_11
=
19
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_13
=
20
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_13
=
CMAKE_PROGRESS_14
=
20
CMAKE_PROGRESS_15
=
CMAKE_PROGRESS_16
=
21
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_17
=
21
CMAKE_PROGRESS_18
=
CMAKE_PROGRESS_19
=
22
CMAKE_PROGRESS_20
=
...
...
@@ -30,11 +30,11 @@ CMAKE_PROGRESS_29 =
CMAKE_PROGRESS_30
=
CMAKE_PROGRESS_31
=
26
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_33
=
27
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_33
=
CMAKE_PROGRESS_34
=
27
CMAKE_PROGRESS_35
=
CMAKE_PROGRESS_36
=
28
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
28
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_39
=
29
CMAKE_PROGRESS_40
=
...
...
build/third_party/mosquitto/plugins/CMakeFiles/progress.marks
View file @
c08ca4d0
5
6
build/third_party/mosquitto/plugins/dynamic-security/CMakeFiles/mosquitto_dynamic_security.dir/progress.make
View file @
c08ca4d0
CMAKE_PROGRESS_1
=
85
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
86
CMAKE_PROGRESS_3
=
86
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
87
CMAKE_PROGRESS_7
=
...
...
build/third_party/mosquitto/plugins/payload-modification/CMakeFiles/mosquitto_payload_modification.dir/progress.make
View file @
c08ca4d0
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_2
=
93
build/third_party/mosquitto/plugins/payload-modification/CMakeFiles/progress.marks
View file @
c08ca4d0
0
1
build/third_party/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
View file @
c08ca4d0
...
...
@@ -8,11 +8,11 @@ CMAKE_PROGRESS_7 =
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
57
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_11
=
CMAKE_PROGRESS_12
=
58
CMAKE_PROGRESS_11
=
58
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_13
=
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_15
=
59
CMAKE_PROGRESS_14
=
59
CMAKE_PROGRESS_15
=
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_17
=
60
CMAKE_PROGRESS_18
=
...
...
@@ -28,11 +28,11 @@ CMAKE_PROGRESS_27 =
CMAKE_PROGRESS_28
=
CMAKE_PROGRESS_29
=
64
CMAKE_PROGRESS_30
=
CMAKE_PROGRESS_31
=
CMAKE_PROGRESS_32
=
65
CMAKE_PROGRESS_31
=
65
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_33
=
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_35
=
66
CMAKE_PROGRESS_34
=
66
CMAKE_PROGRESS_35
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
67
CMAKE_PROGRESS_38
=
...
...
@@ -48,11 +48,11 @@ CMAKE_PROGRESS_47 =
CMAKE_PROGRESS_48
=
CMAKE_PROGRESS_49
=
71
CMAKE_PROGRESS_50
=
CMAKE_PROGRESS_51
=
CMAKE_PROGRESS_52
=
72
CMAKE_PROGRESS_51
=
72
CMAKE_PROGRESS_52
=
CMAKE_PROGRESS_53
=
CMAKE_PROGRESS_54
=
CMAKE_PROGRESS_55
=
73
CMAKE_PROGRESS_54
=
73
CMAKE_PROGRESS_55
=
CMAKE_PROGRESS_56
=
CMAKE_PROGRESS_57
=
74
CMAKE_PROGRESS_58
=
...
...
@@ -68,8 +68,8 @@ CMAKE_PROGRESS_67 =
CMAKE_PROGRESS_68
=
CMAKE_PROGRESS_69
=
78
CMAKE_PROGRESS_70
=
CMAKE_PROGRESS_71
=
CMAKE_PROGRESS_72
=
79
CMAKE_PROGRESS_71
=
79
CMAKE_PROGRESS_72
=
CMAKE_PROGRESS_73
=
CMAKE_PROGRESS_74
=
80
CMAKE_PROGRESS_75
=
...
...
drivers/devicecontrol/devcontrol_common.c
View file @
c08ca4d0
...
...
@@ -37,6 +37,10 @@ const device_didrive device_didrive_control_config_t[]={
.
device_didrive_control
=
tank0206_change
},
{
.
device_id
=
DEVICE_TANK0207
,
.
device_didrive_control
=
tank0207_change
},
{
.
device_id
=
DEVICE_SHIP0301
,
.
device_didrive_control
=
ship0301_change
},
...
...
@@ -52,6 +56,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
.
device_id
=
DEVICE_CAR0101
,
.
device_abnormal_stop
=
car0101_middle_pwm
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -59,6 +64,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
.
device_id
=
DEVICE_CAR0102
,
.
device_abnormal_stop
=
car0102_speed_stop
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -66,6 +72,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
.
device_id
=
DEVICE_CAR0103
,
.
device_abnormal_stop
=
car0103_middle
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -73,6 +80,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
.
device_id
=
DEVICE_CAR0104
,
.
device_abnormal_stop
=
car0104_stop
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -98,13 +106,21 @@ const device_abnormal_close_t devcontrol_config_t[]= {
.
device_abnormal_stop
=
tank0204_stop
,
.
device_close
=
tank_thread_close
,
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all
_default
.
gpio_pwm_pulled
=
tankpwm
_default
},
{
.
device_id
=
DEVICE_TANK0206
,
.
device_abnormal_stop
=
tank0206_middle
,
.
device_close
=
tank_thread_close
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
{
.
device_id
=
DEVICE_TANK0207
,
.
device_abnormal_stop
=
tank0207_middle
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -112,6 +128,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
.
device_id
=
DEVICE_SHIP0301
,
.
device_abnormal_stop
=
ship0301_stop
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -119,6 +136,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
.
device_id
=
DEVICE_PAO_PTZ0401
,
.
device_abnormal_stop
=
PTZ_pwm_init
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -126,6 +144,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
.
device_id
=
DEVICE_ROBOT_DOG0501
,
.
device_abnormal_stop
=
car0101_middle_pwm
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
...
...
@@ -170,8 +189,11 @@ void device_end_close(int device_id) {
my_zlog_error
(
"Error: Device pthread close ID %d not found!"
,
device_id
);
return
;
}
config
->
device_close
();
if
(
config
->
device_close
!=
NULL
)
{
my_zlog_info
(
"Calling device_close for ID %d"
,
device_id
);
config
->
device_close
();
}
}
...
...
drivers/devicecontrol/devcontrol_common.h
View file @
c08ca4d0
...
...
@@ -12,6 +12,7 @@
#include "tank0203_control.h"
#include "tank0204_control.h"
#include "tank0206_control.h"
#include "tank0207_control.h"
#include "ship0301_control.h"
#include "pg0403_serial.h"
#include "tank_common.h"
...
...
@@ -26,6 +27,7 @@
#define DEVICE_TANK0203 203 //M1A2美国坦克
#define DEVICE_TANK0204 204 //美卡隆坦克
#define DEVICE_TANK0206 206 //可以喷水坦克
#define DEVICE_TANK0207 207 //可以发射水弹坦克
#define DEVICE_SHIP0301 301 // 32号船
#define DEVICE_PAO_PTZ0401 401 //云台
#define DEVICE_PG_GPS0403 403 //定位设备
...
...
drivers/devicecontrol/tank0207_control.c
0 → 100755
View file @
c08ca4d0
#include "common.h"
#include "modules_common.h"
#include "tank0207_control.h"
#include "gpio_common.h"
void
tank0207_middle
()
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
tank0207_mode_lift_flont
(
unsigned
char
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
80
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
79
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
79
);
}
else
if
(
gval
>
100
){
int
flont_speed
=
80
+
(
gval
-
70
)
/
10
+
b
;
if
(
flont_speed
>
95
)
flont_speed
=
95
;
pwmWrite
(
PWM_PIN_SPEED
,
flont_speed
);
}
}
void
tank0207_mode_lift_back
(
unsigned
char
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_SPEED
,
70
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_SPEED
,
71
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_SPEED
,
71
);
}
else
if
(
gval
>
100
){
int
back_speed
=
71
-
(
gval
-
70
)
/
10
-
b
;
if
(
back_speed
<
55
)
back_speed
=
55
;
pwmWrite
(
PWM_PIN_SPEED
,
back_speed
);
}
}
void
tank0207_mode_right_flont
(
unsigned
char
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
80
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
79
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
79
);
}
else
if
(
gval
>
100
){
int
flont_speed
=
80
+
(
gval
-
70
)
/
10
+
b
;
if
(
flont_speed
>
95
)
flont_speed
=
95
;
pwmWrite
(
PWM_PIN_CHANGE
,
flont_speed
);
}
}
void
tank0207_mode_right_back
(
unsigned
char
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
else
if
(
gval
<=
60
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
70
);
}
else
if
(
gval
<=
90
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
71
);
}
else
if
(
gval
<=
100
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
71
);
}
else
if
(
gval
>
100
){
int
back_speed
=
71
-
(
gval
-
70
)
/
10
-
b
;
if
(
back_speed
<
55
)
back_speed
=
55
;
pwmWrite
(
PWM_PIN_CHANGE
,
back_speed
);
}
}
int
tank0207_change_grading
(
int
mode
){
int
mode_val
=
0
;
switch
(
mode
){
case
0
:
mode_val
=
0
;
break
;
case
2
:
mode_val
=
10
;
break
;
case
3
:
mode_val
=
20
;
break
;
case
4
:
mode_val
=
30
;
break
;
case
5
:
mode_val
=
50
;
break
;
case
6
:
mode_val
=
60
;
break
;
case
7
:
mode_val
=
70
;
break
;
default
:
mode_val
=
40
;
break
;
}
return
mode_val
;
}
void
tank0207_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
static
int
tank0207_steering_t
=
0
;
static
int
tank0207_front_t
=
0
;
static
int
tank0207_front_val
=
0
;
static
int
tank0207_steering_val
=
0
;
int
tank0206_count
=
40
;
if
(
type
!=
1
)
tank0206_count
=
tank0207_change_grading
(
type
);
if
((
mode
==
1
||
mode
==
2
)
&&
val
==
0
)
tank0207_front_t
=
0
;
if
((
mode
==
3
||
mode
==
4
)
&&
val
==
0
)
tank0207_steering_t
=
0
;
if
(
mode
==
1
&&
val
!=
0
)
{
tank0207_front_val
=
val
;
tank0207_front_t
=
1
;
}
else
if
(
mode
==
2
&&
val
!=
0
)
{
tank0207_front_t
=
2
;
tank0207_front_val
=
val
;
}
if
(
mode
==
3
&&
val
!=
0
)
{
tank0207_steering_t
=
1
;
tank0207_steering_val
=
val
;
}
else
if
(
mode
==
4
&&
val
!=
0
)
{
tank0207_steering_t
=
2
;
tank0207_steering_val
=
val
;
}
if
(
tank0207_front_t
==
0
&&
tank0207_steering_t
==
0
){
tank0207_mode_lift_flont
(
0
);
tank0207_mode_right_flont
(
0
);
}
else
if
(
tank0207_front_t
==
1
&&
tank0207_steering_t
==
0
){
tank0207_mode_lift_flont
(
tank0207_front_val
);
tank0207_mode_right_flont
(
tank0207_front_val
);
}
else
if
(
tank0207_front_t
==
2
&&
tank0207_steering_t
==
0
){
tank0207_mode_lift_back
(
tank0207_front_val
);
tank0207_mode_right_back
(
tank0207_front_val
);
}
else
if
(
tank0207_front_t
==
0
&&
tank0207_steering_t
==
1
){
tank0207_mode_right_flont
(
tank0207_steering_val
+
tank0206_count
);
tank0207_mode_lift_back
(
tank0207_steering_val
+
tank0206_count
);
}
else
if
(
tank0207_front_t
==
0
&&
tank0207_steering_t
==
2
){
tank0207_mode_lift_flont
(
tank0207_steering_val
+
tank0206_count
);
tank0207_mode_right_back
(
tank0207_steering_val
+
tank0206_count
);
}
else
if
(
tank0207_front_t
==
1
&&
tank0207_steering_t
==
1
){
tank0207_mode_lift_flont
(
0
);
tank0207_mode_right_flont
(
tank0207_steering_val
+
tank0206_count
);
}
else
if
(
tank0207_front_t
==
1
&&
tank0207_steering_t
==
2
){
tank0207_mode_lift_flont
(
tank0207_steering_val
+
tank0206_count
);
tank0207_mode_right_flont
(
0
);
}
else
if
(
tank0207_front_t
==
2
&&
tank0207_steering_t
==
1
){
tank0207_mode_lift_back
(
0
);
tank0207_mode_right_back
(
tank0207_steering_val
+
tank0206_count
);
}
else
if
(
tank0207_front_t
==
2
&&
tank0207_steering_t
==
2
){
tank0207_mode_lift_back
(
tank0207_steering_val
+
tank0206_count
);
tank0207_mode_right_back
(
0
);
}
}
drivers/devicecontrol/tank0207_control.h
0 → 100755
View file @
c08ca4d0
#ifndef TANK0207_CONTROL_H__
#define TANK0207_CONTROL_H__
void
tank0207_middle
();
void
tank0207_change
(
unsigned
char
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/tank_common.c
View file @
c08ca4d0
...
...
@@ -51,6 +51,23 @@ const tank_common_back tank_common_config_t[]={
};
static
bool
s_back_status
=
false
;
static
bool
s_backshot_status
=
false
;
/*获取后退状态*/
bool
get_backstatus
(){
return
s_back_status
;
}
/*获取是否在射击,射击状态*/
bool
get_backshotstatus
(){
return
s_backshot_status
;
}
/*获取是否在射击,射击状态*/
bool
set_backshotstatus
(
bool
flag
){
s_backshot_status
=
flag
;
}
static
int
tank_delay_shot_back
(){
if
(
g_device_delay_back_count
<=
g_tank_common_config_t
->
back_time
)
{
tank_shot_back
(
g_tank_common_config_t
->
shot_back_speed
);
...
...
@@ -66,19 +83,22 @@ static int tank_delay_shot_back(){
}
}
static
bool
s_cool_count_index
=
false
;
//射击冷却检测计时变量
static
bool
s_cool_count_index
=
true
;
/*用来判断有射击冷却的检测的状态获取*/
bool
getshot_detection_index
(){
return
s_cool_count_index
;
}
/*用来设置有射击冷却的检测的状态获取*/
bool
setshot_detection_index
(
bool
fla
se
){
s_cool_count_index
=
fla
se
;
bool
setshot_detection_index
(
bool
fla
g
){
s_cool_count_index
=
fla
g
;
}
// 坦克射击操作互斥锁
static
pthread_mutex_t
tankshot_detection_i2c_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_mutex_t
tankshot_detection_i2c_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
// I2C 操作互斥锁
static
int
tankshot_detectionback_count
=
0
;
/*flag=0时初始化冷却时间,1是计时,2是返回计时值,3是重置计时*/
int
tankshot_detection_backcount
(
int
*
cool_time
,
int
flag
){
static
int
cool_count_init
=
0
;
...
...
@@ -92,26 +112,39 @@ int tankshot_detection_backcount(int *cool_time,int flag){
pthread_mutex_lock
(
&
tankshot_detection_i2c_mutex
);
cool_count
++
;
if
(
cool_count
>
cool_count_init
*
2
){
s
_cool_count_index
=
true
;
s
etshot_detection_index
(
true
)
;
}
if
(
cool_count
>
200000
)
cool_count
>
200001
;
if
(
cool_count
>
200000
)
cool_count
=
200001
;
pthread_mutex_unlock
(
&
tankshot_detection_i2c_mutex
);
}
else
if
(
flag
==
2
){
return
cool_count
;
}
else
if
(
flag
==
3
){
pthread_mutex_lock
(
&
tankshot_detection_i2c_mutex
);
cool_count
=
0
;
tankshot_detectionback_count
=
0
;
my_zlog_info
(
"冷却计时重置"
);
pthread_mutex_unlock
(
&
tankshot_detection_i2c_mutex
);
}
else
if
(
flag
==
4
){
tankshot_detectionback_count
=
0
;
}
}
static
void
tankshot_detectionback
(){
static
bool
index
=
0
;
if
(
digitalRead
(
12
)
==
LOW
)
{
s_back_status
=
true
;
softPwmWrite
(
7
,
0
);
index
=
1
;
g_device_delay_back_count
=
0
;
delay_ms
(
100
);
// 延时 100ms,防止抖动
softPwmWrite
(
27
,
0
);
set_backshotstatus
(
false
);
my_zlog_info
(
"检测引脚12拉低"
);
}
if
(
s_back_status
==
true
)
tank_delay_shot_back
();
if
(
s_back_status
==
true
&&
index
==
1
)
tank_delay_shot_back
();
tankshot_detectionback_count
++
;
if
(
tankshot_detectionback_count
>
3000
){
softPwmWrite
(
27
,
0
);
}
}
//多线程处理坦克发射后退线程池
...
...
@@ -134,8 +167,8 @@ void tank_shot_back_stop_task_function(void *arg) {
tank_delay_shot_back
();
break
;
case
DEVICE_TANK0204
:
tankshot_detectionback
();
tankshot_detection_backcount
(
0
,
1
);
tankshot_detectionback
();
break
;
default
:
break
;
...
...
@@ -184,6 +217,7 @@ int tank_shot_back_stop(unsigned char pin,unsigned char val){
}
/*设置s_tank_shot_index_cool,将他置0,让坦克后退*/
void
set_tank_shot_index_cool
(
bool
index
){
s_tank_shot_index_cool
=
index
;
}
...
...
drivers/devicecontrol/tank_common.h
View file @
c08ca4d0
...
...
@@ -22,11 +22,20 @@ void tank_shot_stop_control(int device_id,unsigned char pin,unsigned char val);
/*设置后退的时间重置s*/
void
set_tank_shot_index_cool
(
bool
index
);
/*获取后退状态*/
bool
get_backstatus
();
/*用来判断有射击冷却的检测的状态获取*/
bool
getshot_detection_index
();
/*用来设置有射击冷却的检测的状态获取*/
bool
setshot_detection_index
(
bool
flase
);
bool
setshot_detection_index
(
bool
flag
);
/*获取是否在射击,射击状态*/
bool
get_backshotstatus
();
/*获取是否在射击,射击状态*/
bool
set_backshotstatus
(
bool
flag
);
/*检测的冷却时间,flag=0时初始化冷却时间,2是计时,3是返回计时值*/
int
tankshot_detection_backcount
(
int
*
cool_time
,
int
flag
);
...
...
drivers/gpio/device_init.c
View file @
c08ca4d0
...
...
@@ -94,6 +94,16 @@ const deviceconfig_t device_configs[] = {
.
emergency_code
=
206
},
{
.
device_id
=
DEVICE_TANK0207
,
.
device_name
=
"tank0207"
,
.
gpio_pins
=
{
6
,
16
,
20
,
22
,
23
,
-
1
},
/* 补充GPIO引脚 */
.
gpio_pwms
=
{
5
,
7
,
24
,
26
,
27
,
-
1
},
.
gpio_inputs
=
{
-
1
},
.
device_pwm_init
=
physics_pwm_init
,
.
device_control_stop
=
tank0207_middle
,
/* 补充速度控制函数 */
.
emergency_code
=
207
},
{
.
device_id
=
DEVICE_SHIP0301
,
.
device_name
=
"ship0301"
,
.
gpio_pins
=
{
6
,
16
,
20
,
22
,
23
,
-
1
},
/* 补充GPIO引脚 */
...
...
drivers/gpio/gpio_control.c
View file @
c08ca4d0
...
...
@@ -5,10 +5,11 @@
#include "gpio_control.h"
#define GPIO_ID_THREAD_COUNT 3
#define GPIO_ID_SHOT_ONLYCOOL_COUNT
4
//仅需要打开射击冷却的设备数量
#define GPIO_ID_SHOT_ONLYCOOL_COUNT
5
//仅需要打开射击冷却的设备数量
int
gpio_device_id
[
GPIO_ID_THREAD_COUNT
]
=
{
DEVICE_TANK0202
,
DEVICE_TANK0203
,
DEVICE_TANK0204
};
//需要打开线程池设备号
int
gpio_device_cool_id
[
GPIO_ID_SHOT_ONLYCOOL_COUNT
]
=
{
DEVICE_TANK0202
,
DEVICE_TANK0203
,
DEVICE_TANK0204
,
DEVICE_TANK0206
};
//仅需要打开射击冷却的设备号
static
int
gpio_device_id
[
GPIO_ID_THREAD_COUNT
]
=
{
DEVICE_TANK0202
,
DEVICE_TANK0203
,
DEVICE_TANK0204
};
//需要打开线程池设备号
static
int
gpio_device_cool_id
[
GPIO_ID_SHOT_ONLYCOOL_COUNT
]
=
{
DEVICE_TANK0202
,
DEVICE_TANK0203
,
DEVICE_TANK0204
,
DEVICE_TANK0206
,
DEVICE_TANK0207
};
//仅需要打开射击冷却的设备号
const
gpiocontrol_t
*
gpio_control_config_t
=
NULL
;
//gpio结构体标识
...
...
@@ -24,6 +25,7 @@ void tank0202_pwm_value(int pin,int value);
void
tank0203_pwm_value
(
int
pin
,
int
value
);
void
tank0204_pwm_value
(
int
pin
,
int
value
);
void
tank0206_pwm_value
(
int
pin
,
int
value
);
void
tank0207_pwm_value
(
int
pin
,
int
value
);
void
ship0301_pwm_value
(
int
pin
,
int
value
);
void
dog0501_pwm_value
(
int
pin
,
int
value
);
...
...
@@ -42,7 +44,13 @@ void device_shot_fire_init(TankFireControl* this) {
this
->
state
=
TANK_STATE_READY
;
this
->
shot_interval_ms
=
1000
;
this
->
shot_duration_ms
=
1000
;
}
if
(
g_device_type
==
DEVICE_TANK0204
){
}
else
if
(
g_device_type
==
DEVICE_TANK0207
){
this
->
last_shot_end_time
=
0
;
this
->
shooting_start_time
=
0
;
this
->
state
=
TANK_STATE_READY
;
this
->
shot_interval_ms
=
1000
;
this
->
shot_duration_ms
=
1000
;
}
else
if
(
g_device_type
==
DEVICE_TANK0204
){
this
->
last_shot_end_time
=
0
;
this
->
shooting_start_time
=
0
;
this
->
state
=
TANK_STATE_READY
;
...
...
@@ -79,6 +87,7 @@ int device_shot_cooling_init(){
* @brief 检查射击状态
* @param this 控制器指针
* @return 0=允许射击, -1=禁止射击(冷却中或射击中)
* 此为延时冷却,以时间为主
*/
int
device_fire_check
(
TankFireControl
*
this
)
{
uint64_t
current_time
=
get_current_time_millis
();
...
...
@@ -248,6 +257,12 @@ const gpiocontrol_t gpio_configs[] = {
.
device_pwm_value
=
tank0206_pwm_value
},
{
.
device_id
=
DEVICE_TANK0207
,
.
category_id
=
WATER_TANK
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
tank0207_pwm_value
},
{
.
device_id
=
DEVICE_SHIP0301
,
.
category_id
=
WATER_SHIP
,
.
device_pin_value
=
public_pin_value
,
...
...
@@ -466,6 +481,17 @@ void public_pwm_value(int pin ,int value){
}
/*引脚复用检查,26引脚检查,只有使用的需要*/
int
devicegpio_pwmreuse
(
int
pin
,
int
value
,
int
val
){
if
(
pin
==
26
&&
value
==
1
){
tankshot_detection_backcount
(
NULL
,
4
);
softPwmWrite
(
27
,
val
);
}
if
(
pin
==
26
&&
value
==
0
){
softPwmWrite
(
27
,
val
);
}
}
void
tank0202_pwm_value
(
int
pin
,
int
value
)
{
//软件陪我们控制调速
for
(
int
i
=
0
;
i
<=
g_gpio_softpwmcount
;
i
++
)
{
if
(
pin
==
g_gpioPwm
[
i
])
{
...
...
@@ -481,6 +507,7 @@ void tank0202_pwm_value(int pin,int value) { //软件陪我们控制调速
device_shoting_check
(
27
,
30
);
}
else
{
softPwmWrite
(
pin
,
30
);
devicegpio_pwmreuse
(
pin
,
value
,
30
);
my_zlog_info
(
"pwm:%d"
,
pin
);
}
if
(
limit_status
==
LIMIT_LIFT
)
{
...
...
@@ -495,6 +522,7 @@ void tank0202_pwm_value(int pin,int value) { //软件陪我们控制调速
}
else
if
(
value
==
0
)
{
softPwmWrite
(
pin
,
0
);
devicegpio_pwmreuse
(
pin
,
value
,
0
);
my_zlog_info
(
"pwm:%d,0"
,
pin
);
}
my_zlog_info
(
"tank0202 pwm"
);
...
...
@@ -515,6 +543,7 @@ void tank0203_pwm_value(int pin,int value) { //软件陪我们控制调速
device_shoting_check
(
27
,
30
);
}
else
{
softPwmWrite
(
pin
,
30
);
devicegpio_pwmreuse
(
pin
,
value
,
30
);
my_zlog_info
(
"pwm:%d"
,
pin
);
}
if
(
limit_status
==
LIMIT_LIFT
)
{
...
...
@@ -530,6 +559,7 @@ void tank0203_pwm_value(int pin,int value) { //软件陪我们控制调速
}
else
if
(
value
==
0
)
{
softPwmWrite
(
pin
,
0
);
devicegpio_pwmreuse
(
pin
,
value
,
0
);
my_zlog_info
(
"pwm:%d,0"
,
pin
);
}
my_zlog_info
(
"tank0203 pwm"
);
...
...
@@ -549,12 +579,13 @@ void tank0204_pwm_value(int pin,int value){
if
(
pin
==
27
){
//device_shoting_check(27,100);
if
(
getshot_detection_index
()
==
true
){
softPwmWrite
(
7
,
100
);
tankshot_detection_backcount
(
0
,
3
);
getshot_detection_index
(
false
);
softPwmWrite
(
27
,
100
);
setshot_detection_index
(
true
);
tankshot_detection_backcount
(
NULL
,
3
);
set_backshotstatus
(
true
);
my_zlog_info
(
"冷却完成,射击开始"
);
}
set_tank_shot_index_cool
(
0
);
//
set_tank_shot_index_cool(0);
}
else
if
(
pin
==
5
)
{
softPwmWrite
(
7
,
35
);
my_zlog_info
(
"pwm:7,1"
);
...
...
@@ -562,7 +593,11 @@ void tank0204_pwm_value(int pin,int value){
softPwmWrite
(
5
,
35
);
my_zlog_info
(
"pwm:5,1"
);
}
else
{
softPwmWrite
(
pin
,
60
);
if
(
pin
==
26
&&
get_backshotstatus
()
!=
true
)
{
devicegpio_pwmreuse
(
pin
,
value
,
100
);
softPwmWrite
(
pin
,
60
);
}
if
(
pin
!=
26
)
softPwmWrite
(
pin
,
60
);
my_zlog_info
(
"pwm:%d"
,
pin
);
}
...
...
@@ -584,8 +619,14 @@ void tank0204_pwm_value(int pin,int value){
softPwmWrite
(
5
,
0
);
my_zlog_info
(
"pwm:5,0"
,
pin
);
}
else
{
if
(
pin
!=
27
)
softPwmWrite
(
pin
,
0
);
if
(
pin
!=
27
)
{
if
(
pin
==
26
&&
get_backshotstatus
()
!=
true
){
softPwmWrite
(
pin
,
0
);
devicegpio_pwmreuse
(
pin
,
value
,
0
);
}
if
(
pin
!=
26
)
softPwmWrite
(
pin
,
0
);
my_zlog_info
(
"pwm:%d,0"
,
pin
);
}
}
}
my_zlog_info
(
"tank0204 pwm"
);
...
...
@@ -617,6 +658,32 @@ void tank0206_pwm_value(int pin,int value) { //软件陪我们控制调速
my_zlog_info
(
"tank0206 pwm"
);
}
void
tank0207_pwm_value
(
int
pin
,
int
value
)
{
//软件陪我们控制调速
for
(
int
i
=
0
;
i
<=
g_gpio_softpwmcount
;
i
++
)
{
if
(
pin
==
g_gpioPwm
[
i
])
{
break
;
}
if
(
i
==
g_gpio_softpwmcount
)
{
return
;
}
}
if
(
value
==
1
)
{
if
(
pin
==
27
){
device_shoting_check
(
26
,
100
);
}
else
{
softPwmWrite
(
pin
,
35
);
my_zlog_info
(
"pwm:%d"
,
pin
);
}
}
else
if
(
value
==
0
)
{
if
(
pin
==
27
)
softPwmWrite
(
26
,
0
);
softPwmWrite
(
pin
,
0
);
my_zlog_info
(
"pwm:%d,0"
,
pin
);
}
my_zlog_info
(
"tank0206 pwm"
);
}
void
ship0301_pwm_value
(
int
pin
,
int
value
)
{
//软件陪我们控制调速
for
(
int
i
=
0
;
i
<=
g_gpio_softpwmcount
;
i
++
)
{
if
(
pin
==
g_gpioPwm
[
i
])
{
...
...
drivers/gpio/gpio_init.c
View file @
c08ca4d0
...
...
@@ -72,6 +72,15 @@ void pwm_all_default() {//全部至低电平,车和坦克共用
}
}
void
tankpwm_default
()
{
//全部至低电平,车和坦克共用
for
(
int
i
=
0
;
i
<
g_gpio_softpwmcount
;
i
++
)
{
if
(
g_gpioPwm
[
i
]
!=
27
)
softPwmWrite
(
g_gpioPwm
[
i
],
0
);
}
}
/*物理pwm初始化*/
void
physics_pwm_init
()
{
...
...
drivers/gpio/gpio_init.h
View file @
c08ca4d0
...
...
@@ -30,5 +30,7 @@ void pin_value(int pin,int value);
void
physics_pwm_init
();
void
pwm_value
(
int
pin
,
int
value
);
//软件陪我们控制调速
void
tankpwm_default
();
//坦克专用pwm置0引脚
#endif
modules/http/http_config_mqtt.c
View file @
c08ca4d0
...
...
@@ -53,7 +53,7 @@ int parse_device_config(const char *json_str) {
if
(
cJSON_IsString
(
item
))
{
strncpy
(
g_mqtt_cam_config_t
->
mqtt_servers
[
i
],
item
->
valuestring
,
sizeof
(
g_mqtt_cam_config_t
->
mqtt_servers
[
i
])
-
1
);
g_mqtt_cam_config_t
->
mqtt_servers
[
i
][
sizeof
(
g_mqtt_cam_config_t
->
mqtt_servers
[
i
])
-
1
]
=
'\0'
;
my_zlog_info
(
" [%d] %s"
,
i
,
g_mqtt_cam_config_t
->
mqtt_servers
[
i
]);
my_zlog_info
(
" [%d] %s"
,
i
+
1
,
g_mqtt_cam_config_t
->
mqtt_servers
[
i
]);
i
=
i
+
1
;
}
}
...
...
modules/mqtt/mqtt_verify.c
View file @
c08ca4d0
...
...
@@ -131,7 +131,6 @@ int receive_jwt(cJSON *body) {
my_zlog_debug
(
"在有效期内"
);
pthread_mutex_lock
(
&
g_verify_mutex
);
g_verify_count
=
0
;
my_zlog_info
(
"count: %s"
,
g_verify_count
);
pthread_mutex_unlock
(
&
g_verify_mutex
);
my_zlog_debug
(
"g_verify_count=%d"
,
g_verify_count
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment