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
f71fe029
Commit
f71fe029
authored
Oct 16, 2025
by
957dd
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/self_control' into 'master'
Feature/self control See merge request
!74
parents
8dbb5dd1
743a2a89
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
254 additions
and
162 deletions
+254
-162
CMakeLists.txt
CMakeLists.txt
+4
-2
pthread_open.c
app/main/pthread_open.c
+7
-4
Makefile
build/Makefile
+27
-0
version.h
build/include/version.h
+1
-1
main
build/main
+0
-0
progress.marks
build/third_party/mosquitto/CMakeFiles/progress.marks
+1
-1
progress.make
...osquitto_ctrl/CMakeFiles/mosquitto_ctrl.dir/progress.make
+2
-2
progress.make
...y/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
+2
-2
progress.make
...itto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
+6
-6
progress.make
...y/CMakeFiles/mosquitto_dynamic_security.dir/progress.make
+2
-2
progress.make
...arty/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
+19
-19
progress.marks
build/third_party/mosquitto/src/CMakeFiles/progress.marks
+1
-1
car0104_control.c
drivers/devicecontrol/car0104_control.c
+4
-4
devcontrol_common.h
drivers/devicecontrol/devcontrol_common.h
+9
-0
tank0202_control.c
drivers/devicecontrol/tank0202_control.c
+22
-22
tank0204_control.c
drivers/devicecontrol/tank0204_control.c
+22
-22
tank_common.c
drivers/devicecontrol/tank_common.c
+8
-26
gpio_control.c
drivers/gpio/gpio_control.c
+49
-38
gpio_control.h
drivers/gpio/gpio_control.h
+1
-0
self_devicecontrol.c
drivers/selfcontrol/self_devicecontrol.c
+0
-0
self_devicecontrol.h
drivers/selfcontrol/self_devicecontrol.h
+43
-0
tank_angle.c
drivers/sensors/tank_angle.c
+0
-4
drivers_common.h
include/drivers_common.h
+2
-0
mqtt_infor_handle.c
modules/mqtt/mqtt_infor_handle.c
+20
-3
mqtt_verify.c
modules/mqtt/mqtt_verify.c
+1
-2
pthrpoll.h
modules/thread_pool/pthrpoll.h
+1
-1
No files found.
CMakeLists.txt
View file @
f71fe029
cmake_minimum_required
(
VERSION 3.10
)
cmake_minimum_required
(
VERSION 3.10
)
project
(
car
project
(
car
VERSION 1.2.1
7
VERSION 1.2.1
9
LANGUAGES C
LANGUAGES C
)
)
...
@@ -44,6 +44,7 @@ include_directories(
...
@@ -44,6 +44,7 @@ include_directories(
drivers/network
drivers/network
drivers/sensors
drivers/sensors
drivers/devicecontrol
drivers/devicecontrol
drivers/selfcontrol
modules/logger
modules/logger
modules/delay
modules/delay
modules/thread_pool
modules/thread_pool
...
@@ -60,7 +61,8 @@ file(GLOB_RECURSE SOURCES
...
@@ -60,7 +61,8 @@ file(GLOB_RECURSE SOURCES
drivers/gpio/*.c
drivers/gpio/*.c
drivers/network/*.c
drivers/network/*.c
drivers/sensors/*.c
drivers/sensors/*.c
drivers/devicecontrol/*c
drivers/devicecontrol/*.c
drivers/selfcontrol/*.c
modules/logger/*.c
modules/logger/*.c
modules/delay/*.c
modules/delay/*.c
modules/thread_pool/*.c
modules/thread_pool/*.c
...
...
app/main/pthread_open.c
View file @
f71fe029
...
@@ -39,18 +39,21 @@ int thread_start_init(ThreadFunc thread_exit_time, ThreadFunc thread_mqtt_beat,
...
@@ -39,18 +39,21 @@ int thread_start_init(ThreadFunc thread_exit_time, ThreadFunc thread_mqtt_beat,
//出现意外自动停止
//出现意外自动停止
void
*
thread_exit_time
(
void
*
arg
)
{
void
*
thread_exit_time
(
void
*
arg
)
{
while
(
1
){
while
(
1
){
if
(
get_self_control_index
()
==
false
){
delay_ms
(
100
);
delay_ms
(
100
);
pthread_mutex_lock
(
&
g_exit_count_mutex
);
pthread_mutex_lock
(
&
g_exit_count_mutex
);
g_devcontrol_exit_count
++
;
g_devcontrol_exit_count
++
;
if
(
g_devcontrol_exit_count
>=
5
)
{
if
(
g_devcontrol_exit_count
>=
5
)
{
device_stop
(
g_device_type
);
device_stop
(
g_device_type
);
g_devcontrol_exit_count
=
6
;
g_devcontrol_exit_count
=
6
;
}
}
pthread_mutex_unlock
(
&
g_exit_count_mutex
);
pthread_mutex_unlock
(
&
g_exit_count_mutex
);
}
else
if
(
get_self_control_index
()
==
true
){
delay_ms
(
20
);
set_self_control_time_countfuntion
();
}
}
}
return
NULL
;
return
NULL
;
}
}
...
...
build/Makefile
View file @
f71fe029
...
@@ -942,6 +942,30 @@ drivers/network/ip_reader.c.s:
...
@@ -942,6 +942,30 @@ drivers/network/ip_reader.c.s:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/network/ip_reader.c.s
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/network/ip_reader.c.s
.PHONY
:
drivers/network/ip_reader.c.s
.PHONY
:
drivers/network/ip_reader.c.s
drivers/selfcontrol/self_devicecontrol.o
:
drivers/selfcontrol/self_devicecontrol.c.o
.PHONY
:
drivers/selfcontrol/self_devicecontrol.o
# target to build an object file
drivers/selfcontrol/self_devicecontrol.c.o
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/selfcontrol/self_devicecontrol.c.o
.PHONY
:
drivers/selfcontrol/self_devicecontrol.c.o
drivers/selfcontrol/self_devicecontrol.i
:
drivers/selfcontrol/self_devicecontrol.c.i
.PHONY
:
drivers/selfcontrol/self_devicecontrol.i
# target to preprocess a source file
drivers/selfcontrol/self_devicecontrol.c.i
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/selfcontrol/self_devicecontrol.c.i
.PHONY
:
drivers/selfcontrol/self_devicecontrol.c.i
drivers/selfcontrol/self_devicecontrol.s
:
drivers/selfcontrol/self_devicecontrol.c.s
.PHONY
:
drivers/selfcontrol/self_devicecontrol.s
# target to generate assembly for a file
drivers/selfcontrol/self_devicecontrol.c.s
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/selfcontrol/self_devicecontrol.c.s
.PHONY
:
drivers/selfcontrol/self_devicecontrol.c.s
drivers/sensors/INA226.o
:
drivers/sensors/INA226.c.o
drivers/sensors/INA226.o
:
drivers/sensors/INA226.c.o
.PHONY
:
drivers/sensors/INA226.o
.PHONY
:
drivers/sensors/INA226.o
...
@@ -1978,6 +2002,9 @@ help:
...
@@ -1978,6 +2002,9 @@ help:
@
echo
"... drivers/network/ip_reader.o"
@
echo
"... drivers/network/ip_reader.o"
@
echo
"... drivers/network/ip_reader.i"
@
echo
"... drivers/network/ip_reader.i"
@
echo
"... drivers/network/ip_reader.s"
@
echo
"... drivers/network/ip_reader.s"
@
echo
"... drivers/selfcontrol/self_devicecontrol.o"
@
echo
"... drivers/selfcontrol/self_devicecontrol.i"
@
echo
"... drivers/selfcontrol/self_devicecontrol.s"
@
echo
"... drivers/sensors/INA226.o"
@
echo
"... drivers/sensors/INA226.o"
@
echo
"... drivers/sensors/INA226.i"
@
echo
"... drivers/sensors/INA226.i"
@
echo
"... drivers/sensors/INA226.s"
@
echo
"... drivers/sensors/INA226.s"
...
...
build/include/version.h
View file @
f71fe029
#define PROJECT_VERSION_MAJOR 1
#define PROJECT_VERSION_MAJOR 1
#define PROJECT_VERSION_MINOR 2
#define PROJECT_VERSION_MINOR 2
#define PROJECT_VERSION_PATCH 1
7
#define PROJECT_VERSION_PATCH 1
9
#define GIT_HASH ""
#define GIT_HASH ""
#define BUILD_TIMESTAMP ""
#define BUILD_TIMESTAMP ""
#define BUILD_USER ""
#define BUILD_USER ""
build/main
View file @
f71fe029
No preview for this file type
build/third_party/mosquitto/CMakeFiles/progress.marks
View file @
f71fe029
7
8
7
7
build/third_party/mosquitto/apps/mosquitto_ctrl/CMakeFiles/mosquitto_ctrl.dir/progress.make
View file @
f71fe029
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_2
=
81
CMAKE_PROGRESS_3
=
81
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_5
=
82
CMAKE_PROGRESS_5
=
82
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_6
=
...
...
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
View file @
f71fe029
...
@@ -32,8 +32,8 @@ CMAKE_PROGRESS_31 =
...
@@ -32,8 +32,8 @@ CMAKE_PROGRESS_31 =
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_33
=
12
CMAKE_PROGRESS_33
=
12
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_35
=
13
CMAKE_PROGRESS_35
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_36
=
13
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_38
=
14
CMAKE_PROGRESS_38
=
14
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_39
=
...
...
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
View file @
f71fe029
...
@@ -5,8 +5,8 @@ CMAKE_PROGRESS_4 =
...
@@ -5,8 +5,8 @@ CMAKE_PROGRESS_4 =
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
18
CMAKE_PROGRESS_6
=
18
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_8
=
19
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
CMAKE_PROGRESS_9
=
19
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_11
=
20
CMAKE_PROGRESS_11
=
20
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_12
=
...
@@ -22,11 +22,11 @@ CMAKE_PROGRESS_21 =
...
@@ -22,11 +22,11 @@ CMAKE_PROGRESS_21 =
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_23
=
24
CMAKE_PROGRESS_23
=
24
CMAKE_PROGRESS_24
=
CMAKE_PROGRESS_24
=
CMAKE_PROGRESS_25
=
25
CMAKE_PROGRESS_25
=
CMAKE_PROGRESS_26
=
CMAKE_PROGRESS_26
=
25
CMAKE_PROGRESS_27
=
CMAKE_PROGRESS_27
=
CMAKE_PROGRESS_28
=
26
CMAKE_PROGRESS_28
=
CMAKE_PROGRESS_29
=
CMAKE_PROGRESS_29
=
26
CMAKE_PROGRESS_30
=
CMAKE_PROGRESS_30
=
CMAKE_PROGRESS_31
=
27
CMAKE_PROGRESS_31
=
27
CMAKE_PROGRESS_32
=
CMAKE_PROGRESS_32
=
...
...
build/third_party/mosquitto/plugins/dynamic-security/CMakeFiles/mosquitto_dynamic_security.dir/progress.make
View file @
f71fe029
...
@@ -3,8 +3,8 @@ CMAKE_PROGRESS_2 =
...
@@ -3,8 +3,8 @@ CMAKE_PROGRESS_2 =
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
86
CMAKE_PROGRESS_4
=
86
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_6
=
87
CMAKE_PROGRESS_7
=
87
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
88
CMAKE_PROGRESS_9
=
88
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_10
=
...
...
build/third_party/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
View file @
f71fe029
CMAKE_PROGRESS_1
=
54
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_3
=
55
CMAKE_PROGRESS_4
=
55
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_6
=
56
CMAKE_PROGRESS_7
=
56
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
57
CMAKE_PROGRESS_9
=
57
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_10
=
...
@@ -14,14 +14,14 @@ CMAKE_PROGRESS_13 =
...
@@ -14,14 +14,14 @@ CMAKE_PROGRESS_13 =
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_15
=
59
CMAKE_PROGRESS_15
=
59
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_17
=
60
CMAKE_PROGRESS_18
=
60
CMAKE_PROGRESS_18
=
CMAKE_PROGRESS_19
=
CMAKE_PROGRESS_19
=
CMAKE_PROGRESS_20
=
CMAKE_PROGRESS_20
=
61
CMAKE_PROGRESS_21
=
61
CMAKE_PROGRESS_21
=
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_23
=
CMAKE_PROGRESS_23
=
62
CMAKE_PROGRESS_24
=
62
CMAKE_PROGRESS_24
=
CMAKE_PROGRESS_25
=
CMAKE_PROGRESS_25
=
CMAKE_PROGRESS_26
=
63
CMAKE_PROGRESS_26
=
63
CMAKE_PROGRESS_27
=
CMAKE_PROGRESS_27
=
...
@@ -34,11 +34,11 @@ CMAKE_PROGRESS_33 =
...
@@ -34,11 +34,11 @@ CMAKE_PROGRESS_33 =
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_35
=
66
CMAKE_PROGRESS_35
=
66
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_37
=
67
CMAKE_PROGRESS_38
=
67
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_40
=
68
CMAKE_PROGRESS_41
=
68
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_43
=
69
CMAKE_PROGRESS_43
=
69
CMAKE_PROGRESS_44
=
CMAKE_PROGRESS_44
=
...
@@ -54,8 +54,8 @@ CMAKE_PROGRESS_53 =
...
@@ -54,8 +54,8 @@ CMAKE_PROGRESS_53 =
CMAKE_PROGRESS_54
=
CMAKE_PROGRESS_54
=
CMAKE_PROGRESS_55
=
73
CMAKE_PROGRESS_55
=
73
CMAKE_PROGRESS_56
=
CMAKE_PROGRESS_56
=
CMAKE_PROGRESS_57
=
CMAKE_PROGRESS_57
=
74
CMAKE_PROGRESS_58
=
74
CMAKE_PROGRESS_58
=
CMAKE_PROGRESS_59
=
CMAKE_PROGRESS_59
=
CMAKE_PROGRESS_60
=
75
CMAKE_PROGRESS_60
=
75
CMAKE_PROGRESS_61
=
CMAKE_PROGRESS_61
=
...
@@ -71,6 +71,6 @@ CMAKE_PROGRESS_70 =
...
@@ -71,6 +71,6 @@ CMAKE_PROGRESS_70 =
CMAKE_PROGRESS_71
=
CMAKE_PROGRESS_71
=
CMAKE_PROGRESS_72
=
79
CMAKE_PROGRESS_72
=
79
CMAKE_PROGRESS_73
=
CMAKE_PROGRESS_73
=
CMAKE_PROGRESS_74
=
CMAKE_PROGRESS_74
=
80
CMAKE_PROGRESS_75
=
80
CMAKE_PROGRESS_75
=
build/third_party/mosquitto/src/CMakeFiles/progress.marks
View file @
f71fe029
2
7
2
6
drivers/devicecontrol/car0104_control.c
View file @
f71fe029
...
@@ -81,14 +81,14 @@ void car0104_change(unsigned char *buf) {
...
@@ -81,14 +81,14 @@ void car0104_change(unsigned char *buf) {
unsigned
char
val
=
buf
[
2
];
unsigned
char
val
=
buf
[
2
];
if
(
mode
==
1
)
{
if
(
mode
==
1
)
{
car0104_flont
(
val
);
car0104_flont
(
val
+
10
);
}
else
if
(
mode
==
2
)
{
}
else
if
(
mode
==
2
)
{
car0104_back
(
val
);
car0104_back
(
val
+
10
);
}
else
if
(
mode
==
3
)
{
}
else
if
(
mode
==
3
)
{
if
(
val
!=
0
)
car0104_lift
(
85
);
if
(
val
!=
0
)
car0104_lift
(
100
);
else
car0104_lift
(
0
);
else
car0104_lift
(
0
);
}
else
if
(
mode
==
4
)
{
}
else
if
(
mode
==
4
)
{
if
(
val
!=
0
)
car0104_right
(
85
);
if
(
val
!=
0
)
car0104_right
(
100
);
else
car0104_lift
(
0
);
else
car0104_lift
(
0
);
}
}
...
...
drivers/devicecontrol/devcontrol_common.h
View file @
f71fe029
...
@@ -29,6 +29,15 @@
...
@@ -29,6 +29,15 @@
#define DEVICE_PAO_PTZ0401 401 //云台
#define DEVICE_PAO_PTZ0401 401 //云台
#define DEVICE_ROBOT_DOG0501 501 //机械狗
#define DEVICE_ROBOT_DOG0501 501 //机械狗
/*
*以下为大类
*/
#define LAND_CAR 1
#define MARINE_TANK 2
#define WATER_TANK 3
#define WATER_SHIP 4
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
);
// 车停止
...
...
drivers/devicecontrol/tank0202_control.c
View file @
f71fe029
...
@@ -10,7 +10,7 @@ void tank0202_middle() {
...
@@ -10,7 +10,7 @@ void tank0202_middle() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
}
void
mode_
lift_flon
t
(
unsigned
char
gval
)
{
void
mode_
righ
t
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
@@ -26,7 +26,7 @@ void mode_lift_flont(unsigned char gval) {
...
@@ -26,7 +26,7 @@ void mode_lift_flont(unsigned char gval) {
}
}
}
}
void
mode_lift
_back
(
unsigned
char
gval
)
{
void
mode_lift
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
@@ -41,7 +41,7 @@ void mode_lift_back(unsigned char gval) {
...
@@ -41,7 +41,7 @@ void mode_lift_back(unsigned char gval) {
}
}
}
}
void
mode_
right_
flont
(
unsigned
char
gval
)
{
void
mode_flont
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
@@ -56,7 +56,7 @@ void mode_right_flont(unsigned char gval) {
...
@@ -56,7 +56,7 @@ void mode_right_flont(unsigned char gval) {
}
}
}
}
void
mode_
right_
back
(
unsigned
char
gval
)
{
void
mode_back
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
@@ -128,33 +128,33 @@ void tank0202_change(unsigned char *buf) {
...
@@ -128,33 +128,33 @@ void tank0202_change(unsigned char *buf) {
}
}
if
(
tank0202_front_t
==
0
&&
tank0202_steering_t
==
0
){
if
(
tank0202_front_t
==
0
&&
tank0202_steering_t
==
0
){
mode_
lift_flon
t
(
0
);
mode_
righ
t
(
0
);
mode_
right_
flont
(
0
);
mode_flont
(
0
);
}
else
if
(
tank0202_front_t
==
1
&&
tank0202_steering_t
==
0
){
}
else
if
(
tank0202_front_t
==
1
&&
tank0202_steering_t
==
0
){
mode_
right_
flont
(
tank0202_front_val
+
10
);
mode_flont
(
tank0202_front_val
+
10
);
mode_
lift_flon
t
(
0
);
mode_
righ
t
(
0
);
}
else
if
(
tank0202_front_t
==
2
&&
tank0202_steering_t
==
0
){
}
else
if
(
tank0202_front_t
==
2
&&
tank0202_steering_t
==
0
){
mode_
right_
back
(
tank0202_front_val
+
10
);
mode_back
(
tank0202_front_val
+
10
);
mode_lift
_back
(
0
);
mode_lift
(
0
);
}
else
if
(
tank0202_front_t
==
0
&&
tank0202_steering_t
==
1
){
}
else
if
(
tank0202_front_t
==
0
&&
tank0202_steering_t
==
1
){
mode_lift
_back
(
tank0202_steering_val
+
tank0202_count
+
20
);
mode_lift
(
tank0202_steering_val
+
tank0202_count
+
20
);
mode_
right_
back
(
0
);
mode_back
(
0
);
}
else
if
(
tank0202_front_t
==
0
&&
tank0202_steering_t
==
2
){
}
else
if
(
tank0202_front_t
==
0
&&
tank0202_steering_t
==
2
){
mode_
lift_flon
t
(
tank0202_steering_val
+
tank0202_count
+
20
);
mode_
righ
t
(
tank0202_steering_val
+
tank0202_count
+
20
);
mode_
right_
back
(
0
);
mode_back
(
0
);
}
}
else
if
(
tank0202_front_t
==
1
&&
tank0202_steering_t
==
1
){
else
if
(
tank0202_front_t
==
1
&&
tank0202_steering_t
==
1
){
mode_lift
_back
(
tank0202_steering_val
+
10
);
mode_lift
(
tank0202_steering_val
+
10
);
mode_
right_
flont
(
tank0202_steering_val
+
20
);
mode_flont
(
tank0202_steering_val
+
20
);
}
else
if
(
tank0202_front_t
==
1
&&
tank0202_steering_t
==
2
){
}
else
if
(
tank0202_front_t
==
1
&&
tank0202_steering_t
==
2
){
mode_
lift_flon
t
(
tank0202_steering_val
+
10
);
mode_
righ
t
(
tank0202_steering_val
+
10
);
mode_
right_
flont
(
tank0202_steering_val
+
20
);
mode_flont
(
tank0202_steering_val
+
20
);
}
else
if
(
tank0202_front_t
==
2
&&
tank0202_steering_t
==
1
){
}
else
if
(
tank0202_front_t
==
2
&&
tank0202_steering_t
==
1
){
mode_lift
_back
(
tank0202_steering_val
+
10
);
mode_lift
(
tank0202_steering_val
+
10
);
mode_
right_
back
(
tank0202_steering_val
+
20
);
mode_back
(
tank0202_steering_val
+
20
);
}
else
if
(
tank0202_front_t
==
2
&&
tank0202_steering_t
==
2
){
}
else
if
(
tank0202_front_t
==
2
&&
tank0202_steering_t
==
2
){
mode_
lift_flon
t
(
tank0202_steering_val
+
10
);
mode_
righ
t
(
tank0202_steering_val
+
10
);
mode_
right_
back
(
tank0202_steering_val
+
20
);
mode_back
(
tank0202_steering_val
+
20
);
}
}
...
...
drivers/devicecontrol/tank0204_control.c
View file @
f71fe029
...
@@ -8,7 +8,7 @@ void tank0204_stop() {
...
@@ -8,7 +8,7 @@ void tank0204_stop() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
}
void
tank0204_mode_lift
_flont
(
unsigned
char
gval
)
{
void
tank0204_mode_lift
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
@@ -24,7 +24,7 @@ void tank0204_mode_lift_flont(unsigned char gval) {
...
@@ -24,7 +24,7 @@ void tank0204_mode_lift_flont(unsigned char gval) {
}
}
}
}
void
tank0204_mode_
lift_back
(
unsigned
char
gval
)
{
void
tank0204_mode_
right
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
@@ -39,7 +39,7 @@ void tank0204_mode_lift_back(unsigned char gval) {
...
@@ -39,7 +39,7 @@ void tank0204_mode_lift_back(unsigned char gval) {
}
}
}
}
void
tank0204_mode_
right_back
(
unsigned
char
gval
)
{
void
tank0204_mode_
flont
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
@@ -54,7 +54,7 @@ void tank0204_mode_right_back(unsigned char gval) {
...
@@ -54,7 +54,7 @@ void tank0204_mode_right_back(unsigned char gval) {
}
}
}
}
void
tank0204_mode_
right_flont
(
unsigned
char
gval
)
{
void
tank0204_mode_
back
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
@@ -125,33 +125,33 @@ void tank0204_change(unsigned char *buf) {
...
@@ -125,33 +125,33 @@ void tank0204_change(unsigned char *buf) {
}
}
if
(
tank0204_front_t
==
0
&&
tank0204_steering_t
==
0
){
if
(
tank0204_front_t
==
0
&&
tank0204_steering_t
==
0
){
tank0204_mode_
lift_flon
t
(
0
);
tank0204_mode_
righ
t
(
0
);
tank0204_mode_
right_
flont
(
0
);
tank0204_mode_flont
(
0
);
}
else
if
(
tank0204_front_t
==
1
&&
tank0204_steering_t
==
0
){
}
else
if
(
tank0204_front_t
==
1
&&
tank0204_steering_t
==
0
){
tank0204_mode_
right_
flont
(
tank0204_front_val
+
10
);
tank0204_mode_flont
(
tank0204_front_val
+
10
);
tank0204_mode_
lift_flon
t
(
0
);
tank0204_mode_
righ
t
(
0
);
}
else
if
(
tank0204_front_t
==
2
&&
tank0204_steering_t
==
0
){
}
else
if
(
tank0204_front_t
==
2
&&
tank0204_steering_t
==
0
){
tank0204_mode_
right_
back
(
tank0204_front_val
+
10
);
tank0204_mode_back
(
tank0204_front_val
+
10
);
tank0204_mode_lift
_back
(
0
);
tank0204_mode_lift
(
0
);
}
else
if
(
tank0204_front_t
==
0
&&
tank0204_steering_t
==
1
){
}
else
if
(
tank0204_front_t
==
0
&&
tank0204_steering_t
==
1
){
tank0204_mode_lift
_back
(
tank0204_steering_val
+
tank0204_count
+
20
);
tank0204_mode_lift
(
tank0204_steering_val
+
tank0204_count
);
tank0204_mode_
right_
back
(
0
);
tank0204_mode_back
(
0
);
}
else
if
(
tank0204_front_t
==
0
&&
tank0204_steering_t
==
2
){
}
else
if
(
tank0204_front_t
==
0
&&
tank0204_steering_t
==
2
){
tank0204_mode_
lift_flont
(
tank0204_steering_val
+
tank0204_count
+
20
);
tank0204_mode_
right
(
tank0204_steering_val
+
tank0204_count
);
tank0204_mode_
right_
back
(
0
);
tank0204_mode_back
(
0
);
}
}
else
if
(
tank0204_front_t
==
1
&&
tank0204_steering_t
==
1
){
else
if
(
tank0204_front_t
==
1
&&
tank0204_steering_t
==
1
){
tank0204_mode_lift
_back
(
tank0204_steering_val
+
1
0
);
tank0204_mode_lift
(
tank0204_steering_val
+
tank0204_count
+
10
0
);
tank0204_mode_
right_
flont
(
tank0204_steering_val
+
20
);
tank0204_mode_flont
(
tank0204_steering_val
+
20
);
}
else
if
(
tank0204_front_t
==
1
&&
tank0204_steering_t
==
2
){
}
else
if
(
tank0204_front_t
==
1
&&
tank0204_steering_t
==
2
){
tank0204_mode_
lift_flont
(
tank0204_steering_val
+
1
0
);
tank0204_mode_
right
(
tank0204_steering_val
+
tank0204_count
+
10
0
);
tank0204_mode_
right_
flont
(
tank0204_steering_val
+
20
);
tank0204_mode_flont
(
tank0204_steering_val
+
20
);
}
else
if
(
tank0204_front_t
==
2
&&
tank0204_steering_t
==
1
){
}
else
if
(
tank0204_front_t
==
2
&&
tank0204_steering_t
==
1
){
tank0204_mode_lift
_back
(
tank0204_steering_val
+
1
0
);
tank0204_mode_lift
(
tank0204_steering_val
+
tank0204_count
+
10
0
);
tank0204_mode_
right_
back
(
tank0204_steering_val
+
20
);
tank0204_mode_back
(
tank0204_steering_val
+
20
);
}
else
if
(
tank0204_front_t
==
2
&&
tank0204_steering_t
==
2
){
}
else
if
(
tank0204_front_t
==
2
&&
tank0204_steering_t
==
2
){
tank0204_mode_
lift_flont
(
tank0204_steering_val
+
1
0
);
tank0204_mode_
right
(
tank0204_steering_val
+
tank0204_count
+
10
0
);
tank0204_mode_
right_
back
(
tank0204_steering_val
+
20
);
tank0204_mode_back
(
tank0204_steering_val
+
20
);
}
}
}
}
...
...
drivers/devicecontrol/tank_common.c
View file @
f71fe029
...
@@ -14,30 +14,11 @@ int g_tank_shot_index_cool=1;//状态机,用于冷却状态机,坦克接收射
...
@@ -14,30 +14,11 @@ int g_tank_shot_index_cool=1;//状态机,用于冷却状态机,坦克接收射
void
tank_shot_back
(
unsigned
char
gval
)
{
void
tank_shot_back
(
unsigned
char
gval
)
{
int
b
=
0
;
int
b
=
0
;
if
(
gval
<
50
)
{
unsigned
char
valt
[
3
]
=
{
0
};
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
valt
[
1
]
=
2
;
pwmWrite
(
PWM_PIN_SPEED
,
75
);
if
(
gval
==
0
)
valt
[
2
]
=
0
;
}
else
if
(
gval
<=
60
)
{
else
valt
[
2
]
=
gval
;
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0202
)
pwmWrite
(
PWM_PIN_CHANGE
,
71
);
device_walk_control
(
g_device_type
,
valt
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0203
)
pwmWrite
(
PWM_PIN_CHANGE
,
79
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0203
)
pwmWrite
(
PWM_PIN_SPEED
,
71
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0204
)
pwmWrite
(
PWM_PIN_CHANGE
,
79
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0204
)
pwmWrite
(
PWM_PIN_SPEED
,
71
);
}
else
if
(
gval
<=
70
)
{
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0202
)
pwmWrite
(
PWM_PIN_CHANGE
,
70
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0203
)
pwmWrite
(
PWM_PIN_CHANGE
,
80
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0203
)
pwmWrite
(
PWM_PIN_SPEED
,
70
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0204
)
pwmWrite
(
PWM_PIN_CHANGE
,
80
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0204
)
pwmWrite
(
PWM_PIN_SPEED
,
70
);
}
else
if
(
gval
>
70
){
int
change_1
=
80
+
(
gval
-
70
)
/
10
+
b
;
int
speed_2
=
70
-
(
gval
-
70
)
/
10
-
b
;
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0202
)
pwmWrite
(
PWM_PIN_CHANGE
,
speed_2
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0203
)
pwmWrite
(
PWM_PIN_SPEED
,
speed_2
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0203
)
pwmWrite
(
PWM_PIN_CHANGE
,
change_1
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0204
)
pwmWrite
(
PWM_PIN_SPEED
,
speed_2
);
if
(
g_tank_common_config_t
->
device_id
==
DEVICE_TANK0204
)
pwmWrite
(
PWM_PIN_CHANGE
,
change_1
);
}
}
}
...
@@ -104,7 +85,6 @@ void tank_shot_back_stop_task_function(void *arg) {
...
@@ -104,7 +85,6 @@ void tank_shot_back_stop_task_function(void *arg) {
delay_ms
(
1
);
delay_ms
(
1
);
}
}
}
}
}
}
...
@@ -145,7 +125,9 @@ int tank_shot_back_stop(unsigned char pin,unsigned char val){
...
@@ -145,7 +125,9 @@ int tank_shot_back_stop(unsigned char pin,unsigned char val){
}
}
/*销毁坦克使用的线程池,让其正常销毁,只有在tank相关设备号下才有用,最后销毁都会到device——common.h中*/
/*
* @brief 销毁坦克使用的线程池,让其正常销毁,只有在tank相关设备号下才有用,最后销毁都会到device——common.h中
*/
void
tank_thread_close
(){
void
tank_thread_close
(){
thread_pool_destroy
(
pool_tank_t
);
thread_pool_destroy
(
pool_tank_t
);
thread_pool_destroy
(
g_pool_device_gpio_control_t
);
thread_pool_destroy
(
g_pool_device_gpio_control_t
);
...
...
drivers/gpio/gpio_control.c
View file @
f71fe029
#include "common.h"
#include "common.h"
#include "app_device_common.h"
#include "drivers_common.h"
#include "modules_common.h"
#include "gpio_control.h"
#include "gpio_control.h"
#include "tank_angle.h"
#include "device_init.h"
#include "gpio_init.h"
#include "devcontrol_common.h"
#include "http_request.h"
#define GPIO_ID_THREAD_COUNT 3
#define GPIO_ID_THREAD_COUNT 3
...
@@ -19,6 +17,7 @@ void car0103_pin_value(int pin,int value);
...
@@ -19,6 +17,7 @@ void car0103_pin_value(int pin,int value);
void
car0104_pin_value
(
int
pin
,
int
value
);
void
car0104_pin_value
(
int
pin
,
int
value
);
void
public_pwm_value
(
int
pin
,
int
value
);
void
public_pwm_value
(
int
pin
,
int
value
);
void
car0103_pwm_value
(
int
pin
,
int
value
);
void
tank0202_pwm_value
(
int
pin
,
int
value
);
void
tank0202_pwm_value
(
int
pin
,
int
value
);
void
tank0203_pwm_value
(
int
pin
,
int
value
);
void
tank0203_pwm_value
(
int
pin
,
int
value
);
void
tank0204_pwm_value
(
int
pin
,
int
value
);
void
tank0204_pwm_value
(
int
pin
,
int
value
);
...
@@ -26,34 +25,20 @@ void tank0206_pwm_value(int pin,int value);
...
@@ -26,34 +25,20 @@ void tank0206_pwm_value(int pin,int value);
void
ship0301_pwm_value
(
int
pin
,
int
value
);
void
ship0301_pwm_value
(
int
pin
,
int
value
);
void
dog0501_pwm_value
(
int
pin
,
int
value
);
void
dog0501_pwm_value
(
int
pin
,
int
value
);
uint64_t
g_tank_shot_interval_ms
=
5000
;
//冷却时间
uint64_t
g_tank_shot_ms
=
1000
;
//射击时间
TankFireControl
g_device_shot_t
;
// 真正的结构体变量
TankFireControl
g_device_shot_t
;
// 真正的结构体变量
/*获取时间戳函数*/
// uint64_t get_shot_timestamp_ms() {
// struct timeval tv;
// if (gettimeofday(&tv, NULL) == -1) {
// my_zlog_error("gettimeofday failed");
// return 0;
// }
// return (uint64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000;
// }
/**
/**
* @brief 初始化坦克射击控制器
* @brief 初始化坦克射击控制器
* @param this 控制器指针
* @param this 控制器指针
* @param interval_ms 冷却时间(毫秒)
* @param
shot_
interval_ms 冷却时间(毫秒)
* @param duration_ms 射击持续时间(毫秒)
* @param
shot_
duration_ms 射击持续时间(毫秒)
*/
*/
void
device_shot_fire_init
(
TankFireControl
*
this
,
uint32_t
interval_ms
,
uint32_t
duration_ms
)
{
void
device_shot_fire_init
(
TankFireControl
*
this
)
{
this
->
last_shot_end_time
=
0
;
this
->
last_shot_end_time
=
0
;
this
->
shooting_start_time
=
0
;
this
->
shooting_start_time
=
0
;
this
->
state
=
TANK_STATE_READY
;
this
->
state
=
TANK_STATE_READY
;
this
->
shot_interval_ms
=
interval_ms
;
this
->
shot_interval_ms
=
5000
;
this
->
shot_duration_ms
=
duration_ms
;
this
->
shot_duration_ms
=
1000
;
}
}
/*
/*
...
@@ -61,14 +46,14 @@ void device_shot_fire_init(TankFireControl* this, uint32_t interval_ms, uint32_t
...
@@ -61,14 +46,14 @@ void device_shot_fire_init(TankFireControl* this, uint32_t interval_ms, uint32_t
**对需要射击冷却的进行初始化
**对需要射击冷却的进行初始化
*/
*/
int
device_shot_cooling_init
(){
int
device_shot_cooling_init
(){
if
(
g_device_type
==
DEVICE_TANK0202
||
g_device_type
==
DEVICE_TANK0203
){
for
(
int
i
=
0
;
i
<
GPIO_ID_THREAD_COUNT
;
i
++
){
my_zlog_info
(
"using %d shot init"
,
g_device_type
);
if
(
g_device_type
==
gpio_device_id
[
i
]){
device_shot_fire_init
(
&
g_device_shot_t
,
g_tank_shot_interval_ms
,
g_tank_shot_ms
);
my_zlog_info
(
"using %d shot init"
,
g_device_type
);
}
else
{
device_shot_fire_init
(
&
g_device_shot_t
);
return
-
1
;
return
0
;
}
}
}
return
-
1
;
return
0
;
}
}
/**
/**
...
@@ -114,17 +99,18 @@ int device_fire_check(TankFireControl* this) {
...
@@ -114,17 +99,18 @@ int device_fire_check(TankFireControl* this) {
}
}
/*
/*
*设备加上冷却射击切换
*
@brief
设备加上冷却射击切换
*/
*/
int
device_shoting_check
(
int
pin
,
int
val
){
int
device_shoting_check
(
int
pin
,
int
val
){
if
(
device_fire_check
(
&
g_device_shot_t
)
!=
0
){
if
(
device_fire_check
(
&
g_device_shot_t
)
!=
0
){
softPwmWrite
(
pin
,
0
);
softPwmWrite
(
pin
,
0
);
}
else
{
}
else
if
(
device_fire_check
(
&
g_device_shot_t
)
==
0
)
{
softPwmWrite
(
pin
,
val
);
softPwmWrite
(
pin
,
val
);
}
}
}
}
/*坦克限位线程函数*/
/*
* @brief 坦克限位线程函数*/
void
tank_angle_limit_function
(
void
*
arg_gpio
){
void
tank_angle_limit_function
(
void
*
arg_gpio
){
static
int
limit_log_count
=
0
;
static
int
limit_log_count
=
0
;
if
(
arg_gpio
!=
NULL
)
{
if
(
arg_gpio
!=
NULL
)
{
...
@@ -157,7 +143,7 @@ void tank_angle_limit_function(void *arg_gpio){
...
@@ -157,7 +143,7 @@ void tank_angle_limit_function(void *arg_gpio){
/*角度限位线程池初始化*/
/*角度限位线程池初始化*/
void
device_gpio_control_threadpoll_init
(){
void
device_gpio_control_threadpoll_init
(){
int
*
arg_gpio
=
malloc
(
sizeof
(
int
));
int
*
arg_gpio
=
malloc
(
sizeof
(
int
));
my_zlog_info
(
"device_gpio_control_threadpoll_init start
\n
"
);
my_zlog_info
(
"device_gpio_control_threadpoll_init start"
);
*
arg_gpio
=
2
;
*
arg_gpio
=
2
;
g_pool_device_gpio_control_t
=
thread_pool_init
(
1
,
1
);
g_pool_device_gpio_control_t
=
thread_pool_init
(
1
,
1
);
thread_pool_add_task
(
g_pool_device_gpio_control_t
,
tank_angle_limit_function
,
arg_gpio
);
thread_pool_add_task
(
g_pool_device_gpio_control_t
,
tank_angle_limit_function
,
arg_gpio
);
...
@@ -167,59 +153,70 @@ void device_gpio_control_threadpoll_init(){
...
@@ -167,59 +153,70 @@ void device_gpio_control_threadpoll_init(){
const
gpiocontrol_t
gpio_configs
[]
=
{
const
gpiocontrol_t
gpio_configs
[]
=
{
{
{
.
device_id
=
DEVICE_CAR0101
,
.
device_id
=
DEVICE_CAR0101
,
.
category_id
=
LAND_CAR
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
public_pwm_value
.
device_pwm_value
=
public_pwm_value
},
},
{
{
.
device_id
=
DEVICE_CAR0102
,
.
device_id
=
DEVICE_CAR0102
,
.
category_id
=
LAND_CAR
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
public_pwm_value
.
device_pwm_value
=
public_pwm_value
},
},
{
{
.
device_id
=
DEVICE_CAR0103
,
.
device_id
=
DEVICE_CAR0103
,
.
category_id
=
LAND_CAR
,
.
device_pin_value
=
car0103_pin_value
,
.
device_pin_value
=
car0103_pin_value
,
.
device_pwm_value
=
public_pwm_value
.
device_pwm_value
=
public_pwm_value
},
},
{
{
.
device_id
=
DEVICE_CAR0104
,
.
device_id
=
DEVICE_CAR0104
,
.
category_id
=
LAND_CAR
,
.
device_pin_value
=
car0104_pin_value
,
.
device_pin_value
=
car0104_pin_value
,
.
device_pwm_value
=
public_pwm_value
.
device_pwm_value
=
public_pwm_value
},
},
{
{
.
device_id
=
DEVICE_TANK0202
,
.
device_id
=
DEVICE_TANK0202
,
.
category_id
=
MARINE_TANK
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
tank0202_pwm_value
,
.
device_pwm_value
=
tank0202_pwm_value
,
.
device_gpio_pthread_create
=
device_gpio_control_threadpoll_init
.
device_gpio_pthread_create
=
device_gpio_control_threadpoll_init
},
},
{
{
.
device_id
=
DEVICE_TANK0203
,
.
device_id
=
DEVICE_TANK0203
,
.
category_id
=
MARINE_TANK
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
tank0203_pwm_value
,
.
device_pwm_value
=
tank0203_pwm_value
,
.
device_gpio_pthread_create
=
device_gpio_control_threadpoll_init
.
device_gpio_pthread_create
=
device_gpio_control_threadpoll_init
},
},
{
{
.
device_id
=
DEVICE_TANK0204
,
.
device_id
=
DEVICE_TANK0204
,
.
category_id
=
MARINE_TANK
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
tank0204_pwm_value
,
.
device_pwm_value
=
tank0204_pwm_value
,
.
device_gpio_pthread_create
=
device_gpio_control_threadpoll_init
.
device_gpio_pthread_create
=
device_gpio_control_threadpoll_init
},
},
{
{
.
device_id
=
DEVICE_TANK0206
,
.
device_id
=
DEVICE_TANK0206
,
.
category_id
=
WATER_TANK
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
tank0206_pwm_value
.
device_pwm_value
=
tank0206_pwm_value
},
},
{
{
.
device_id
=
DEVICE_SHIP0301
,
.
device_id
=
DEVICE_SHIP0301
,
.
category_id
=
WATER_SHIP
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
ship0301_pwm_value
.
device_pwm_value
=
ship0301_pwm_value
},
},
{
{
.
device_id
=
DEVICE_PAO_PTZ0401
,
.
device_id
=
DEVICE_PAO_PTZ0401
,
.
category_id
=
0
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
public_pwm_value
.
device_pwm_value
=
public_pwm_value
},
},
{
{
.
device_id
=
DEVICE_ROBOT_DOG0501
,
.
device_id
=
DEVICE_ROBOT_DOG0501
,
.
category_id
=
0
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
dog0501_pwm_value
.
device_pwm_value
=
dog0501_pwm_value
},
},
...
@@ -401,14 +398,28 @@ void tank0204_pwm_value(int pin,int value){
...
@@ -401,14 +398,28 @@ void tank0204_pwm_value(int pin,int value){
if
(
pin
==
27
){
if
(
pin
==
27
){
device_shoting_check
(
27
,
30
);
device_shoting_check
(
27
,
30
);
}
else
{
}
else
if
(
pin
==
5
)
{
softPwmWrite
(
7
,
30
);
my_zlog_info
(
"pwm:7,0"
);
}
else
if
(
pin
==
7
)
{
softPwmWrite
(
5
,
30
);
my_zlog_info
(
"pwm:5,0"
);
}
else
{
softPwmWrite
(
pin
,
30
);
softPwmWrite
(
pin
,
30
);
my_zlog_info
(
"pwm:%d"
,
pin
);
my_zlog_info
(
"pwm:%d"
,
pin
);
}
}
}
else
if
(
value
==
0
)
{
}
else
if
(
value
==
0
)
{
softPwmWrite
(
pin
,
0
);
if
(
pin
==
5
)
{
my_zlog_info
(
"pwm:%d,0"
,
pin
);
softPwmWrite
(
7
,
0
);
my_zlog_info
(
"pwm:7,0"
);
}
else
if
(
pin
==
7
)
{
softPwmWrite
(
5
,
0
);
my_zlog_info
(
"pwm:5,0"
,
pin
);
}
else
{
softPwmWrite
(
pin
,
0
);
my_zlog_info
(
"pwm:%d,0"
,
pin
);
}
}
}
my_zlog_info
(
"tank0204 pwm"
);
my_zlog_info
(
"tank0204 pwm"
);
}
}
...
...
drivers/gpio/gpio_control.h
View file @
f71fe029
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
typedef
struct
{
typedef
struct
{
int
device_id
;
// 设备ID (101, 102等)备名称
int
device_id
;
// 设备ID (101, 102等)备名称
int
category_id
;
void
(
*
device_pwm_value
)(
int
pin
,
int
val
);
// PWM初始化函数指针
void
(
*
device_pwm_value
)(
int
pin
,
int
val
);
// PWM初始化函数指针
void
(
*
device_pin_value
)(
int
pin
,
int
value
);
// 速度控制函数指针
void
(
*
device_pin_value
)(
int
pin
,
int
value
);
// 速度控制函数指针
void
(
*
device_gpio_pthread_create
)(
void
);
void
(
*
device_gpio_pthread_create
)(
void
);
...
...
drivers/selfcontrol/self_devicecontrol.c
0 → 100644
View file @
f71fe029
This diff is collapsed.
Click to expand it.
drivers/selfcontrol/self_devicecontrol.h
0 → 100644
View file @
f71fe029
#ifndef SELF_DEVICECONTROL_H
#define SELF_DEVICECONTROL_H
/**
* @file self_devicecontrol.h
* @brief 设备自己控制模块头文件
*/
#define DEVICE_WALK_SIGN_MAX 100
#define DEVICE_SELF_CONTROL_OPEN 1
#define DEVICE_SELF_CONTROL_CLOSE 0
//结构体,用来存放这些
typedef
struct
{
int
id_run
[
DEVICE_WALK_SIGN_MAX
];
int
id_run_count
;
int
run_cool
[
DEVICE_WALK_SIGN_MAX
];
int
timed_run
[
DEVICE_WALK_SIGN_MAX
];
}
devicecontroltask_t
;
// 单个设备动作数据结构
typedef
struct
{
int
mode
[
DEVICE_WALK_SIGN_MAX
];
int
val
[
DEVICE_WALK_SIGN_MAX
];
int
action_count
;
}
device_automatic_date_t
;
void
set_self_control_time_countfuntion
();
//计时
void
self_control_thread_close
();
void
receive_self_contorl_mqtt
(
cJSON
*
body
);
void
receive_self_contorl_date_mqtt
(
cJSON
*
body
);
//数据保存
bool
get_self_control_index
();
void
set_self_control_index
(
bool
index
);
#endif
\ No newline at end of file
drivers/sensors/tank_angle.c
View file @
f71fe029
...
@@ -2,10 +2,6 @@
...
@@ -2,10 +2,6 @@
#include "common.h"
#include "common.h"
#include "ads1115.h"
#include "ads1115.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
double
tank_angle
(){
double
tank_angle
(){
double
angle
=
0
;
double
angle
=
0
;
float
angle_shot
=
ads1115_read_channel
(
2
);
float
angle_shot
=
ads1115_read_channel
(
2
);
...
...
include/drivers_common.h
View file @
f71fe029
...
@@ -5,5 +5,6 @@
...
@@ -5,5 +5,6 @@
#include "gpio_common.h"
#include "gpio_common.h"
#include "ip_reader.h"
#include "ip_reader.h"
#include "sensors_common.h"
#include "sensors_common.h"
#include"self_devicecontrol.h"
#endif
#endif
\ No newline at end of file
modules/mqtt/mqtt_infor_handle.c
View file @
f71fe029
...
@@ -5,14 +5,17 @@
...
@@ -5,14 +5,17 @@
#include "drivers_common.h"
#include "drivers_common.h"
#include "modules_common.h"
#include "modules_common.h"
int
g_heartbeat_count
=
0
;
int
g_heartbeat_count
=
0
;
//心跳计数
/*
*
*/
pthread_mutex_t
g_exit_count_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
//互斥锁
pthread_mutex_t
g_exit_count_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
//互斥锁
int
g_devcontrol_exit_count
=
0
;
int
g_devcontrol_exit_count
=
0
;
int
g_message_type
=
0
;
int
g_message_type
=
0
;
//接收的mqtt的g_message_type
unsigned
char
g_valt
[
4
];
//存放mqtt接收的tpye,mode等
static
unsigned
char
g_valt
[
4
];
//存放mqtt接收的tpye,mode等
//心跳发送格式*5/2
//心跳发送格式*5/2
void
heartbeat_send
()
{
void
heartbeat_send
()
{
...
@@ -254,12 +257,19 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
...
@@ -254,12 +257,19 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
break
;
break
;
case
3
:
case
3
:
message_3_judyverify
(
body
);
message_3_judyverify
(
body
);
set_self_control_index
(
false
);
my_zlog_debug
(
"进入pwm控制"
);
my_zlog_debug
(
"进入pwm控制"
);
break
;
break
;
case
4
:
case
4
:
message_4_judyverify
(
body
);
message_4_judyverify
(
body
);
set_self_control_index
(
false
);
my_zlog_debug
(
"进入引脚控制"
);
my_zlog_debug
(
"进入引脚控制"
);
break
;
break
;
case
5
:
audio_wheat_init
();
audio_speaker_init
();
my_zlog_debug
(
"执行麦和喇叭命令"
);
break
;
case
2001
:
case
2001
:
audioplay_mqtt_receive
(
body
);
audioplay_mqtt_receive
(
body
);
my_zlog_debug
(
"进入音频播放"
);
my_zlog_debug
(
"进入音频播放"
);
...
@@ -312,6 +322,13 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
...
@@ -312,6 +322,13 @@ int device_message_receive(cJSON *json){//接收到的控制设备的mqtt消息
control_pthread_function
(
"close"
);
control_pthread_function
(
"close"
);
my_zlog_debug
(
"关闭控制台推送"
);
my_zlog_debug
(
"关闭控制台推送"
);
break
;
break
;
case
2025
:
receive_self_contorl_mqtt
(
body
);
my_zlog_debug
(
"device self comtrol"
);
break
;
case
2026
:
receive_self_contorl_date_mqtt
(
body
);
my_zlog_debug
(
"device self comtrol date save"
);
default
:
default
:
break
;
break
;
}
}
...
...
modules/mqtt/mqtt_verify.c
View file @
f71fe029
...
@@ -180,7 +180,6 @@ int message2006_verify(cJSON *body){
...
@@ -180,7 +180,6 @@ int message2006_verify(cJSON *body){
}
}
return
0
;
return
0
;
}
}
/*接收到是否打开验证的函数*/
/*接收到是否打开验证的函数*/
...
@@ -200,7 +199,7 @@ int message2013_recverigy_open(cJSON *body){
...
@@ -200,7 +199,7 @@ int message2013_recverigy_open(cJSON *body){
my_zlog_debug
(
"verify open"
);
my_zlog_debug
(
"verify open"
);
}
}
return
0
;
return
0
;
}
}
/*发送是否打开验证的mqtt给后端验证*/
/*发送是否打开验证的mqtt给后端验证*/
int
message_sendopen_verify
(){
int
message_sendopen_verify
(){
...
...
modules/thread_pool/pthrpoll.h
View file @
f71fe029
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
#define PTHRPOLL_H
#define PTHRPOLL_H
// 为了让头文件自给自足,直接包含它所需要的依赖
// 为了让头文件自给自足,直接包含它所需要的依赖
#include
<common.h>
#include
"common.h"
// 任务结构体
// 任务结构体
typedef
struct
Task
{
typedef
struct
Task
{
...
...
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