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
67dda630
Commit
67dda630
authored
Mar 04, 2026
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入了小车0102的方向盘控制,修改了变量的类型
parent
c7920af7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
577 additions
and
170 deletions
+577
-170
main.c
app/main/main.c
+1
-1
main.h
app/main/main.h
+3
-2
pthread_open.c
app/main/pthread_open.c
+15
-3
pthread_open.h
app/main/pthread_open.h
+4
-1
Makefile
build/Makefile
+27
-0
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
+4
-4
progress.make
...y/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
+1
-1
progress.make
...itto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
+6
-6
progress.marks
build/third_party/mosquitto/lib/CMakeFiles/progress.marks
+1
-1
progress.marks
...d/third_party/mosquitto/lib/cpp/CMakeFiles/progress.marks
+1
-1
progress.make
...arty/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
+14
-14
car0101_control.c
drivers/devicecontrol/car0101_control.c
+7
-7
car0101_control.h
drivers/devicecontrol/car0101_control.h
+2
-1
car0102_control.c
drivers/devicecontrol/car0102_control.c
+262
-26
car0102_control.h
drivers/devicecontrol/car0102_control.h
+5
-2
car0103_control.c
drivers/devicecontrol/car0103_control.c
+7
-7
car0103_control.h
drivers/devicecontrol/car0103_control.h
+2
-1
car0104_control.c
drivers/devicecontrol/car0104_control.c
+7
-7
car0104_control.h
drivers/devicecontrol/car0104_control.h
+2
-1
car0105_control.c
drivers/devicecontrol/car0105_control.c
+7
-7
car0105_control.h
drivers/devicecontrol/car0105_control.h
+1
-1
devcontrol_common.c
drivers/devicecontrol/devcontrol_common.c
+1
-1
devcontrol_common.h
drivers/devicecontrol/devcontrol_common.h
+2
-2
ptz0401_control.c
drivers/devicecontrol/ptz0401_control.c
+1
-1
ptz0401_control.h
drivers/devicecontrol/ptz0401_control.h
+2
-1
ptz0404_control.c
drivers/devicecontrol/ptz0404_control.c
+1
-1
ptz0404_control.h
drivers/devicecontrol/ptz0404_control.h
+2
-1
ship0301_control.c
drivers/devicecontrol/ship0301_control.c
+8
-8
ship0301_control.h
drivers/devicecontrol/ship0301_control.h
+2
-1
steering_control.c
drivers/devicecontrol/steering_control.c
+69
-0
steering_control.h
drivers/devicecontrol/steering_control.h
+18
-0
tank0202_control.c
drivers/devicecontrol/tank0202_control.c
+8
-8
tank0202_control.h
drivers/devicecontrol/tank0202_control.h
+2
-1
tank0203_control.c
drivers/devicecontrol/tank0203_control.c
+8
-8
tank0203_control.h
drivers/devicecontrol/tank0203_control.h
+2
-1
tank0204_control.c
drivers/devicecontrol/tank0204_control.c
+8
-8
tank0204_control.h
drivers/devicecontrol/tank0204_control.h
+2
-1
tank0206_control.c
drivers/devicecontrol/tank0206_control.c
+8
-8
tank0206_control.h
drivers/devicecontrol/tank0206_control.h
+2
-1
tank0207_control.c
drivers/devicecontrol/tank0207_control.c
+8
-8
tank0207_control.h
drivers/devicecontrol/tank0207_control.h
+2
-1
tank_common.c
drivers/devicecontrol/tank_common.c
+5
-5
tank_common.h
drivers/devicecontrol/tank_common.h
+2
-2
self_devicecontrol.c
drivers/selfcontrol/self_devicecontrol.c
+1
-1
drivers_common.h
include/drivers_common.h
+2
-0
mqtt_infor_handle.c
modules/mqtt/mqtt_infor_handle.c
+31
-6
No files found.
app/main/main.c
View file @
67dda630
...
...
@@ -80,7 +80,7 @@ int main()
int
thread_rc
=
thread_start_init
(
thread_exit_time
,
thread_mqtt_beat
,
thread_open_browser
,
thread_mqtt_reconnect
,
thread_time_calculation
,
thread_play_mp3
);
thread_open_browser
,
thread_mqtt_reconnect
,
thread_time_calculation
,
thread_play_mp3
,
thread_steering_control
);
if
(
thread_rc
!=
0
)
{
my_zlog_warn
(
"多线程初始化失败"
);
...
...
app/main/main.h
View file @
67dda630
...
...
@@ -33,8 +33,9 @@ int device_shot_cooling_init();
/*线程初始化函数*/
int
thread_start_init
(
ThreadFunc
thread_exit_time
,
ThreadFunc
thread_mqtt_beat
,
ThreadFunc
thread_open_browser
,
ThreadFunc
thread_mqtt_reconnect
,
ThreadFunc
thread_time_calculation
,
ThreadFunc
thread_play_mp3
);
ThreadFunc
thread_open_browser
,
ThreadFunc
thread_mqtt_reconnect
,
ThreadFunc
thread_time_calculation
,
ThreadFunc
thread_play_mp3
,
ThreadFunc
thread_steering_control
);
/*像服务器请求*/
int
request_date
();
...
...
app/main/pthread_open.c
View file @
67dda630
...
...
@@ -5,7 +5,7 @@
#include "pthread_open.h"
#include "go_deploy.h"
#define PTHREAD_MAX
6
#define PTHREAD_MAX
7
pthread_t
g_thread
[
PTHREAD_MAX
];
// 全局线程句柄数组(或传参)
...
...
@@ -17,7 +17,7 @@ void *g_args[PTHREAD_MAX] = {NULL};
int
thread_start_init
(
ThreadFunc
thread_exit_time
,
ThreadFunc
thread_mqtt_beat
,
ThreadFunc
thread_open_browser
,
ThreadFunc
thread_mqtt_reconnect
,
ThreadFunc
thread_time_calculation
,
ThreadFunc
thread_play_mp3
)
ThreadFunc
thread_time_calculation
,
ThreadFunc
thread_play_mp3
,
ThreadFunc
thread_steering_control
)
{
ThreadFunc
thread_funcs
[]
=
{
...
...
@@ -26,7 +26,8 @@ int thread_start_init(ThreadFunc thread_exit_time, ThreadFunc thread_mqtt_beat,
thread_open_browser
,
thread_mqtt_reconnect
,
thread_time_calculation
,
thread_play_mp3
};
thread_play_mp3
,
thread_steering_control
};
for
(
int
i
=
0
;
i
<
PTHREAD_MAX
;
i
++
)
{
...
...
@@ -298,6 +299,17 @@ void *thread_play_mp3(void *arg)
return
NULL
;
}
// 方向盘控制线程:100ms周期调用平滑处理
void
*
thread_steering_control
(
void
*
arg
)
{
my_zlog_info
(
"steering_pthread"
);
while
(
1
)
{
steering_control_process
();
delay_ms
(
25
);
}
return
NULL
;
}
// 等待线程结束
void
thread_end_close
()
{
...
...
app/main/pthread_open.h
View file @
67dda630
...
...
@@ -6,13 +6,16 @@ typedef void *(*ThreadFunc)(void *);
int
thread_start_init
(
ThreadFunc
thread_exit_time
,
ThreadFunc
thread_mqtt_beat
,
ThreadFunc
thread_open_browser
,
ThreadFunc
thread_mqtt_reconnect
,
ThreadFunc
thread_time_calculation
,
ThreadFunc
thread_play_mp3
);
ThreadFunc
thread_time_calculation
,
ThreadFunc
thread_play_mp3
,
ThreadFunc
thread_steering_control
);
void
*
thread_exit_time
(
void
*
arg
)
;
//异常停止线程
void
*
thread_mqtt_beat
(
void
*
arg
)
;
//心跳线程
void
*
thread_open_browser
(
void
*
arg
)
;
//启动游览器线程
void
*
thread_mqtt_reconnect
(
void
*
arg
)
;
//mqtt自带重连线程
void
*
thread_time_calculation
(
void
*
arg
)
;
//延时计算延迟
void
*
thread_play_mp3
(
void
*
arg
);
//等待播放音频线程
void
*
thread_steering_control
(
void
*
arg
);
//方向盘控制线程
void
thread_end_close
()
;
...
...
build/Makefile
View file @
67dda630
...
...
@@ -809,6 +809,30 @@ drivers/devicecontrol/ship0301_control.c.s:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/ship0301_control.c.s
.PHONY
:
drivers/devicecontrol/ship0301_control.c.s
drivers/devicecontrol/steering_control.o
:
drivers/devicecontrol/steering_control.c.o
.PHONY
:
drivers/devicecontrol/steering_control.o
# target to build an object file
drivers/devicecontrol/steering_control.c.o
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/steering_control.c.o
.PHONY
:
drivers/devicecontrol/steering_control.c.o
drivers/devicecontrol/steering_control.i
:
drivers/devicecontrol/steering_control.c.i
.PHONY
:
drivers/devicecontrol/steering_control.i
# target to preprocess a source file
drivers/devicecontrol/steering_control.c.i
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/steering_control.c.i
.PHONY
:
drivers/devicecontrol/steering_control.c.i
drivers/devicecontrol/steering_control.s
:
drivers/devicecontrol/steering_control.c.s
.PHONY
:
drivers/devicecontrol/steering_control.s
# target to generate assembly for a file
drivers/devicecontrol/steering_control.c.s
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/steering_control.c.s
.PHONY
:
drivers/devicecontrol/steering_control.c.s
drivers/devicecontrol/tank0202_control.o
:
drivers/devicecontrol/tank0202_control.c.o
.PHONY
:
drivers/devicecontrol/tank0202_control.o
...
...
@@ -2189,6 +2213,9 @@ help:
@
echo
"... drivers/devicecontrol/ship0301_control.o"
@
echo
"... drivers/devicecontrol/ship0301_control.i"
@
echo
"... drivers/devicecontrol/ship0301_control.s"
@
echo
"... drivers/devicecontrol/steering_control.o"
@
echo
"... drivers/devicecontrol/steering_control.i"
@
echo
"... drivers/devicecontrol/steering_control.s"
@
echo
"... drivers/devicecontrol/tank0202_control.o"
@
echo
"... drivers/devicecontrol/tank0202_control.i"
@
echo
"... drivers/devicecontrol/tank0202_control.s"
...
...
build/main
View file @
67dda630
No preview for this file type
build/third_party/mosquitto/CMakeFiles/progress.marks
View file @
67dda630
7
5
7
4
build/third_party/mosquitto/apps/mosquitto_ctrl/CMakeFiles/mosquitto_ctrl.dir/progress.make
View file @
67dda630
...
...
@@ -6,9 +6,9 @@ CMAKE_PROGRESS_5 =
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_7
=
83
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
CMAKE_PROGRESS_10
=
84
CMAKE_PROGRESS_9
=
84
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_11
=
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_13
=
85
CMAKE_PROGRESS_12
=
85
CMAKE_PROGRESS_13
=
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto.dir/progress.make
View file @
67dda630
...
...
@@ -41,5 +41,5 @@ CMAKE_PROGRESS_40 =
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
14
CMAKE_PROGRESS_43
=
CMAKE_PROGRESS_44
=
15
CMAKE_PROGRESS_44
=
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
View file @
67dda630
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_1
=
15
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
16
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
16
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
17
CMAKE_PROGRESS_7
=
...
...
@@ -38,8 +38,8 @@ CMAKE_PROGRESS_37 =
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_39
=
28
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_41
=
29
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
29
CMAKE_PROGRESS_43
=
CMAKE_PROGRESS_44
=
30
CMAKE_PROGRESS_44
=
build/third_party/mosquitto/lib/CMakeFiles/progress.marks
View file @
67dda630
3
2
3
1
build/third_party/mosquitto/lib/cpp/CMakeFiles/progress.marks
View file @
67dda630
1
7
1
6
build/third_party/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
View file @
67dda630
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
56
CMAKE_PROGRESS_2
=
56
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_6
=
57
CMAKE_PROGRESS_5
=
57
CMAKE_PROGRESS_6
=
CMAKE_PROGRESS_7
=
CMAKE_PROGRESS_8
=
58
CMAKE_PROGRESS_9
=
...
...
@@ -31,20 +31,20 @@ CMAKE_PROGRESS_30 =
CMAKE_PROGRESS_31
=
CMAKE_PROGRESS_32
=
66
CMAKE_PROGRESS_33
=
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_35
=
67
CMAKE_PROGRESS_34
=
67
CMAKE_PROGRESS_35
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_38
=
68
CMAKE_PROGRESS_37
=
68
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_41
=
69
CMAKE_PROGRESS_40
=
69
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_43
=
CMAKE_PROGRESS_44
=
70
CMAKE_PROGRESS_43
=
70
CMAKE_PROGRESS_44
=
CMAKE_PROGRESS_45
=
CMAKE_PROGRESS_46
=
CMAKE_PROGRESS_47
=
71
CMAKE_PROGRESS_46
=
71
CMAKE_PROGRESS_47
=
CMAKE_PROGRESS_48
=
CMAKE_PROGRESS_49
=
72
CMAKE_PROGRESS_50
=
...
...
drivers/devicecontrol/car0101_control.c
View file @
67dda630
...
...
@@ -24,7 +24,7 @@ void car0101_middle_pwm() {//车停止pwm值
}
/*车的速度转向函数*/
void
car0101_mode_1_flont
(
unsigned
char
gval
)
{
void
car0101_mode_1_flont
(
int
gval
)
{
int
a
=
0
,
b
=
1
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -38,7 +38,7 @@ void car0101_mode_1_flont(unsigned char gval) {
}
}
void
car0101_mode_2_back
(
unsigned
char
gval
)
{
void
car0101_mode_2_back
(
int
gval
)
{
int
b
=
0
,
a
=
1
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -54,7 +54,7 @@ void car0101_mode_2_back(unsigned char gval) {
}
void
car0101_mode_3_left
(
unsigned
char
gval
)
{
void
car0101_mode_3_left
(
int
gval
)
{
int
b
=
15
;
if
(
gval
<
45
){
car_calculate_L_R
(
90
);
...
...
@@ -65,7 +65,7 @@ void car0101_mode_3_left(unsigned char gval) {
}
}
void
car0101_mode_4_right
(
unsigned
char
gval
)
{
void
car0101_mode_4_right
(
int
gval
)
{
int
b
=
10
;
if
(
gval
<
45
){
car_calculate_L_R
(
90
);
...
...
@@ -76,9 +76,9 @@ void car0101_mode_4_right(unsigned char gval) {
}
}
void
car0101_control_change
(
unsigned
char
*
buf
)
{
//车速度和转向引脚数值处理函数
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
car0101_control_change
(
int
*
buf
)
{
//车速度和转向引脚数值处理函数
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
switch
(
mode
){
case
1
:
car0101_mode_1_flont
(
val
);
...
...
drivers/devicecontrol/car0101_control.h
View file @
67dda630
...
...
@@ -2,7 +2,7 @@
#define CAR0101_CONTROL_H
void
car0101_control_change
(
unsigned
char
*
buf
);
void
car0101_control_change
(
int
*
buf
);
void
car0101_middle_pwm
();
#endif
\ No newline at end of file
drivers/devicecontrol/car0102_control.c
View file @
67dda630
This diff is collapsed.
Click to expand it.
drivers/devicecontrol/car0102_control.h
View file @
67dda630
#ifndef CAR0102_CONTROL_H__
#define CAR0102_CONTROL_H__
void
car0102_speed_stop
();
//小车的停止
void
car0102_speed_stop
(
void
);
void
car0102_speed_change
(
int
*
buf
);
void
car0102_speed_change
(
unsigned
char
*
buf
);
//小车的改变值
void
car0102_control_steering_change_process
(
int
*
buf
);
void
car0102_steering_smooth_all
(
void
);
#endif
\ No newline at end of file
drivers/devicecontrol/car0103_control.c
View file @
67dda630
...
...
@@ -8,7 +8,7 @@ void car0103_middle() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
mode_car0103_lift_flont
(
unsigned
char
gval
)
{
void
mode_car0103_lift_flont
(
int
gval
)
{
int
b
=
1
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -23,7 +23,7 @@ void mode_car0103_lift_flont(unsigned char gval) {
}
}
void
mode_car0103_lift_back
(
unsigned
char
gval
)
{
void
mode_car0103_lift_back
(
int
gval
)
{
int
b
=
1
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -37,7 +37,7 @@ void mode_car0103_lift_back(unsigned char gval) {
}
}
void
mode_car0103_right_flont
(
unsigned
char
gval
)
{
void
mode_car0103_right_flont
(
int
gval
)
{
int
b
=
1
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -51,7 +51,7 @@ void mode_car0103_right_flont(unsigned char gval) {
}
}
void
mode_car0103_right_back
(
unsigned
char
gval
)
{
void
mode_car0103_right_back
(
int
gval
)
{
int
b
=
1
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -66,9 +66,9 @@ void mode_car0103_right_back(unsigned char gval) {
}
/*挖机的速度处理接口*/
void
car0103_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
car0103_change
(
int
*
buf
)
{
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
static
int
modecount_car0103
=
0
;
if
(
mode
==
1
)
{
//mode_lift_flont(val);
...
...
drivers/devicecontrol/car0103_control.h
View file @
67dda630
...
...
@@ -5,6 +5,6 @@
void
car0103_middle
();
/*挖机的速度处理接口*/
void
car0103_change
(
unsigned
char
*
buf
);
void
car0103_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/car0104_control.c
View file @
67dda630
...
...
@@ -9,7 +9,7 @@ void car0104_stop() {
}
//铲车后退
void
car0104_back
(
unsigned
char
gval
)
{
void
car0104_back
(
int
gval
)
{
int
b
=
7
;
int
c
=
2
;
if
(
gval
<
50
)
{
...
...
@@ -27,7 +27,7 @@ void car0104_back(unsigned char gval) {
}
//铲车前进
void
car0104_flont
(
unsigned
char
gval
)
{
void
car0104_flont
(
int
gval
)
{
int
b
=
7
;
int
c
=
2
;
if
(
gval
<
50
)
{
...
...
@@ -44,7 +44,7 @@ void car0104_flont(unsigned char gval) {
}
//铲车右
void
car0104_right
(
unsigned
char
gval
)
{
void
car0104_right
(
int
gval
)
{
int
b
=
5
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -61,7 +61,7 @@ void car0104_right(unsigned char gval) {
}
//铲车左
void
car0104_lift
(
unsigned
char
gval
)
{
void
car0104_lift
(
int
gval
)
{
int
b
=
5
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -76,9 +76,9 @@ void car0104_lift(unsigned char gval) {
}
}
void
car0104_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
car0104_change
(
int
*
buf
)
{
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
if
(
mode
==
1
)
{
car0104_flont
(
val
+
10
);
...
...
drivers/devicecontrol/car0104_control.h
View file @
67dda630
...
...
@@ -3,6 +3,6 @@
void
car0104_stop
();
void
car0104_change
(
unsigned
char
*
buf
);
void
car0104_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/car0105_control.c
View file @
67dda630
...
...
@@ -308,7 +308,7 @@ void car0105_serial_stop(){
/*车的速度转向函数*/
void
car0105_mode_1_flont
(
unsigned
char
gval
)
{
void
car0105_mode_1_flont
(
int
gval
)
{
if
(
gval
<
50
)
{
my_zlog_info
(
"val:%d"
,
gval
);
serial_send
(
&
car_serial
,
forward_close_command
,
sizeof
(
forward_close_command
));
...
...
@@ -318,7 +318,7 @@ void car0105_mode_1_flont(unsigned char gval) {
}
}
void
car0105_mode_2_back
(
unsigned
char
gval
)
{
void
car0105_mode_2_back
(
int
gval
)
{
if
(
gval
<
50
)
{
serial_send
(
&
car_serial
,
forward_close_command
,
sizeof
(
forward_close_command
));
serial_send
(
&
car_serial
,
back_close_command
,
sizeof
(
back_close_command
));
...
...
@@ -329,7 +329,7 @@ void car0105_mode_2_back(unsigned char gval) {
}
void
car0105_mode_3_left
(
unsigned
char
gval
)
{
void
car0105_mode_3_left
(
int
gval
)
{
if
(
gval
<
45
){
serial_send
(
&
car_serial
,
left_close_command
,
sizeof
(
left_close_command
));
serial_send
(
&
car_serial
,
right_close_command
,
sizeof
(
right_close_command
));
...
...
@@ -338,7 +338,7 @@ void car0105_mode_3_left(unsigned char gval) {
}
}
void
car0105_mode_4_right
(
unsigned
char
gval
)
{
void
car0105_mode_4_right
(
int
gval
)
{
if
(
gval
<
45
){
serial_send
(
&
car_serial
,
left_close_command
,
sizeof
(
left_close_command
));
serial_send
(
&
car_serial
,
right_close_command
,
sizeof
(
right_close_command
));
...
...
@@ -347,9 +347,9 @@ void car0105_mode_4_right(unsigned char gval) {
}
}
void
car0105_control_change
(
unsigned
char
*
buf
)
{
//车速度和转向引脚数值处理函数
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
car0105_control_change
(
int
*
buf
)
{
//车速度和转向引脚数值处理函数
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
serial_stop_index
=
true
;
switch
(
mode
){
case
1
:
...
...
drivers/devicecontrol/car0105_control.h
View file @
67dda630
...
...
@@ -5,7 +5,7 @@
int
car0105_serial_run
();
void
car0105_control_change
(
unsigned
char
*
buf
);
void
car0105_control_change
(
int
*
buf
);
void
car0105_serial_stop
();
...
...
drivers/devicecontrol/devcontrol_common.c
View file @
67dda630
...
...
@@ -222,7 +222,7 @@ void device_end_close(int device_id) {
}
void
device_walk_control
(
int
device_id
,
unsigned
char
*
valt
)
{
void
device_walk_control
(
int
device_id
,
int
*
valt
)
{
const
device_didrive
*
config
=
NULL
;
// 查找设备配置
...
...
drivers/devicecontrol/devcontrol_common.h
View file @
67dda630
...
...
@@ -56,7 +56,7 @@ typedef struct {
typedef
struct
{
int
device_id
;
// 设备ID (101, 102等)
void
(
*
device_didrive_control
)(
unsigned
char
*
valt
);
// PWM初始化函数指针
void
(
*
device_didrive_control
)(
int
*
valt
);
// PWM初始化函数指针
}
device_didrive
;
...
...
@@ -65,7 +65,7 @@ void device_stop(int device_id);
void
device_end_close
(
int
device_id
);
void
device_walk_control
(
int
device_id
,
unsigned
char
*
valt
);
void
device_walk_control
(
int
device_id
,
int
*
valt
);
void
device_serial_exit_run
();
...
...
drivers/devicecontrol/ptz0401_control.c
View file @
67dda630
...
...
@@ -208,7 +208,7 @@ void ptz_pwm_stop(void)
}
/* ===================== 指令解析 ===================== */
void
PTZ_pwm_change
(
unsigned
char
*
buf
)
void
PTZ_pwm_change
(
int
*
buf
)
{
// 假设 buf[1] 是命令字,通常协议里会有停止命令(例如 0 或 5)
// 如果收到 0 或者未定义的命令,应该调用 stop
...
...
drivers/devicecontrol/ptz0401_control.h
View file @
67dda630
...
...
@@ -4,7 +4,7 @@
void
ptz0401_pwm_task_function
(
void
*
arg
);
void
pwm_PTZ_hz
();
void
PTZ_pwm_init
();
void
PTZ_pwm_change
(
unsigned
char
*
buf
);
void
PTZ_pwm_change
(
int
*
buf
);
void
ptz_pwm_stop
();
#endif
\ No newline at end of file
drivers/devicecontrol/ptz0404_control.c
View file @
67dda630
...
...
@@ -207,7 +207,7 @@ void ptz0404_pwm_stop(void)
}
/* ===================== 指令解析 ===================== */
void
ptz0404_pwm_change
(
unsigned
char
*
buf
)
void
ptz0404_pwm_change
(
int
*
buf
)
{
// 假设 buf[1] 是命令字,通常协议里会有停止命令(例如 0 或 5)
// 如果收到 0 或者未定义的命令,应该调用 stop
...
...
drivers/devicecontrol/ptz0404_control.h
View file @
67dda630
...
...
@@ -5,7 +5,7 @@ void ptz0404_pwm_task_function(void *arg);
void
pwm_ptz0404_hz
();
void
ptz0404_pwm_init
();
void
ptz0404_pwm_change
(
unsigned
char
*
buf
);
void
ptz0404_pwm_change
(
int
*
buf
);
void
ptz0404_pwm_stop
();
#endif
\ No newline at end of file
drivers/devicecontrol/ship0301_control.c
View file @
67dda630
...
...
@@ -8,7 +8,7 @@ void ship0301_stop() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
ship0301_mode_lift_flont
(
unsigned
char
gval
)
{
void
ship0301_mode_lift_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -24,7 +24,7 @@ void ship0301_mode_lift_flont(unsigned char gval) {
}
}
void
ship0301_mode_lift_back
(
unsigned
char
gval
)
{
void
ship0301_mode_lift_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -39,7 +39,7 @@ void ship0301_mode_lift_back(unsigned char gval) {
}
}
void
ship0301_mode_right_back
(
unsigned
char
gval
)
{
void
ship0301_mode_right_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -54,7 +54,7 @@ void ship0301_mode_right_back(unsigned char gval) {
}
}
void
ship0301_mode_right_flont
(
unsigned
char
gval
)
{
void
ship0301_mode_right_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -91,10 +91,10 @@ int ship0301_change_grading(int mode){
}
void
ship0301_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
ship0301_change
(
int
*
buf
)
{
int
type
=
buf
[
0
];
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
static
int
ship0301_steering_t
=
0
;
static
int
ship0301_front_t
=
0
;
...
...
drivers/devicecontrol/ship0301_control.h
View file @
67dda630
...
...
@@ -5,5 +5,5 @@
void
ship0301_stop
();
void
ship0301_change
(
unsigned
char
*
buf
);
void
ship0301_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/steering_control.c
0 → 100644
View file @
67dda630
#include "steering_control.h"
#include "devcontrol_common.h"
#include "gpio_common.h"
static
SteeringControl
s_steering_devices
[]
=
{
{
DEVICE_CAR0101
,
"car0101"
,
NULL
,
NULL
},
{
DEVICE_CAR0102
,
"car0102"
,
car0102_control_steering_change_process
,
car0102_steering_smooth_all
},
{
DEVICE_CAR0103
,
"car0103"
,
NULL
,
NULL
},
{
DEVICE_CAR0104
,
"car0104"
,
NULL
,
NULL
},
{
DEVICE_CAR0105
,
"car0105"
,
NULL
,
NULL
},
{
DEVICE_TANK0202
,
"tank0202"
,
NULL
,
NULL
},
{
DEVICE_TANK0203
,
"tank0203"
,
NULL
,
NULL
},
{
DEVICE_TANK0204
,
"tank0204"
,
NULL
,
NULL
},
{
DEVICE_TANK0206
,
"tank0206"
,
NULL
,
NULL
},
{
DEVICE_TANK0207
,
"tank0207"
,
NULL
,
NULL
},
{
0
,
"unknown"
,
NULL
,
NULL
}
};
SteeringControl
*
get_steering_control
(
void
)
{
int
i
=
0
;
while
(
s_steering_devices
[
i
].
id
!=
0
)
{
if
(
s_steering_devices
[
i
].
id
==
g_device_type
)
{
return
&
s_steering_devices
[
i
];
}
i
++
;
}
return
NULL
;
}
// 线程调用:通过结构体分发到对应设备的平滑处理函数
void
steering_control_process
(
void
)
{
static
SteeringControl
*
ctrl
=
NULL
;
if
(
ctrl
==
NULL
)
{
my_zlog_info
(
"steering_control_process: ctrl is NULL"
);
ctrl
=
get_steering_control
();
}
if
(
ctrl
&&
ctrl
->
smooth_process_func
)
{
ctrl
->
smooth_process_func
();
}
}
// MQTT调用:通过结构体分发到对应设备的方向盘接收函数
void
steering_mqtt_recv
(
cJSON
*
body
)
{
static
SteeringControl
*
ctrl
=
NULL
;
if
(
ctrl
==
NULL
)
{
ctrl
=
get_steering_control
();
}
if
(
ctrl
&&
ctrl
->
mqtt_recv_func
)
{
cJSON
*
pwm_ctrl
=
cJSON_GetObjectItem
(
body
,
"pwm_ctrl"
);
cJSON
*
pin_setctrl
=
cJSON_GetObjectItem
(
body
,
"pin_setctrl"
);
if
(
pwm_ctrl
==
NULL
||
pin_setctrl
==
NULL
)
{
return
;
}
cJSON
*
mode
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"mode"
);
// mode=1 速度,mode=2 转向(unsigned char)
cJSON
*
type
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"type"
);
cJSON
*
val
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"val"
);
// val为pwm的值 0~100(unsigned char)(unsigned char)
int
modeTemp
=
mode
->
valueint
;
int
typeTemp
=
type
->
valueint
;
int
valTemp
=
val
->
valueint
;
int
buf
[
3
]
=
{
typeTemp
,
modeTemp
,
valTemp
};
my_zlog_debug
(
"typeTemp:%d,modeTemp:%d,valTemp:%d"
,
buf
[
0
],
buf
[
1
],
buf
[
2
]);
ctrl
->
mqtt_recv_func
(
buf
);
}
}
drivers/devicecontrol/steering_control.h
0 → 100644
View file @
67dda630
#ifndef STEERING_CONTROL_H__
#define STEERING_CONTROL_H__
#include "common.h"
typedef
struct
{
int
id
;
char
name
[
32
];
void
(
*
mqtt_recv_func
)(
int
*
buf
);
// 方向盘MQTT数据处理(buf[0]=mode, buf[1]=val)
void
(
*
smooth_process_func
)(
void
);
// 线程平滑处理(速度+转向合并)
}
SteeringControl
;
SteeringControl
*
get_steering_control
(
void
);
void
steering_control_process
(
void
);
void
steering_mqtt_recv
(
cJSON
*
body
);
#endif
drivers/devicecontrol/tank0202_control.c
View file @
67dda630
...
...
@@ -10,7 +10,7 @@ void tank0202_middle() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
mode_right
(
unsigned
char
gval
)
{
void
mode_right
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -26,7 +26,7 @@ void mode_right(unsigned char gval) {
}
}
void
mode_lift
(
unsigned
char
gval
)
{
void
mode_lift
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -41,7 +41,7 @@ void mode_lift(unsigned char gval) {
}
}
void
mode_flont
(
unsigned
char
gval
)
{
void
mode_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -56,7 +56,7 @@ void mode_flont(unsigned char gval) {
}
}
void
mode_back
(
unsigned
char
gval
)
{
void
mode_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -97,10 +97,10 @@ int tank0202_change_grading(int mode){
return
mode_val
;
}
void
tank0202_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
tank0202_change
(
int
*
buf
)
{
int
type
=
buf
[
0
];
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
static
int
tank0202_steering_t
=
0
;
static
int
tank0202_front_t
=
0
;
...
...
drivers/devicecontrol/tank0202_control.h
View file @
67dda630
...
...
@@ -3,6 +3,6 @@
void
tank0202_middle
();
void
tank0202_change
(
unsigned
char
*
buf
);
void
tank0202_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/tank0203_control.c
View file @
67dda630
...
...
@@ -12,7 +12,7 @@ void tank0203_middle() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
tank0203_mode_lift_flont
(
unsigned
char
gval
)
{
void
tank0203_mode_lift_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -28,7 +28,7 @@ void tank0203_mode_lift_flont(unsigned char gval) {
}
}
void
tank0203_mode_lift_back
(
unsigned
char
gval
)
{
void
tank0203_mode_lift_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -43,7 +43,7 @@ void tank0203_mode_lift_back(unsigned char gval) {
}
}
void
tank0203_mode_right_back
(
unsigned
char
gval
)
{
void
tank0203_mode_right_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -58,7 +58,7 @@ void tank0203_mode_right_back(unsigned char gval) {
}
}
void
tank0203_mode_right_flont
(
unsigned
char
gval
)
{
void
tank0203_mode_right_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -100,10 +100,10 @@ int tank0203_change_grading(int mode){
//tank0203控制函数
void
tank0203_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
tank0203_change
(
int
*
buf
)
{
int
type
=
buf
[
0
];
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
static
int
tank0203_steering_t
=
0
;
static
int
tank0203_front_t
=
0
;
static
int
tank0203_front_val
=
0
;
...
...
drivers/devicecontrol/tank0203_control.h
View file @
67dda630
...
...
@@ -3,6 +3,6 @@
void
tank0203_middle
();
void
tank0203_change
(
unsigned
char
*
buf
);
void
tank0203_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/tank0204_control.c
View file @
67dda630
...
...
@@ -8,7 +8,7 @@ void tank0204_stop() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
tank0204_mode_lift
(
unsigned
char
gval
)
{
void
tank0204_mode_lift
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -24,7 +24,7 @@ void tank0204_mode_lift(unsigned char gval) {
}
}
void
tank0204_mode_right
(
unsigned
char
gval
)
{
void
tank0204_mode_right
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -39,7 +39,7 @@ void tank0204_mode_right(unsigned char gval) {
}
}
void
tank0204_mode_flont
(
unsigned
char
gval
)
{
void
tank0204_mode_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -54,7 +54,7 @@ void tank0204_mode_flont(unsigned char gval) {
}
}
void
tank0204_mode_back
(
unsigned
char
gval
)
{
void
tank0204_mode_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -94,10 +94,10 @@ int tank0204_change_grading(int mode){
return
mode_val
;
}
void
tank0204_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
tank0204_change
(
int
*
buf
)
{
int
type
=
buf
[
0
];
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
static
int
tank0204_steering_t
=
0
;
static
int
tank0204_front_t
=
0
;
...
...
drivers/devicecontrol/tank0204_control.h
View file @
67dda630
...
...
@@ -3,6 +3,6 @@
void
tank0204_stop
();
void
tank0204_change
(
unsigned
char
*
buf
);
void
tank0204_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/tank0206_control.c
View file @
67dda630
...
...
@@ -8,7 +8,7 @@ void tank0206_middle() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
tank0206_mode_lift_flont
(
unsigned
char
gval
)
{
void
tank0206_mode_lift_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -26,7 +26,7 @@ void tank0206_mode_lift_flont(unsigned char gval) {
}
}
void
tank0206_mode_lift_back
(
unsigned
char
gval
)
{
void
tank0206_mode_lift_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -43,7 +43,7 @@ void tank0206_mode_lift_back(unsigned char gval) {
}
}
void
tank0206_mode_right_flont
(
unsigned
char
gval
)
{
void
tank0206_mode_right_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
...
...
@@ -62,7 +62,7 @@ void tank0206_mode_right_flont(unsigned char gval) {
}
}
void
tank0206_mode_right_back
(
unsigned
char
gval
)
{
void
tank0206_mode_right_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -110,10 +110,10 @@ int tank0206_change_grading(int mode){
return
mode_val
;
}
void
tank0206_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
tank0206_change
(
int
*
buf
)
{
int
type
=
buf
[
0
];
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
static
int
tank0206_steering_t
=
0
;
static
int
tank0206_front_t
=
0
;
...
...
drivers/devicecontrol/tank0206_control.h
View file @
67dda630
...
...
@@ -3,6 +3,6 @@
void
tank0206_middle
();
void
tank0206_change
(
unsigned
char
*
buf
);
void
tank0206_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/tank0207_control.c
View file @
67dda630
...
...
@@ -8,7 +8,7 @@ void tank0207_middle() {
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
}
void
tank0207_mode_lift_flont
(
unsigned
char
gval
)
{
void
tank0207_mode_lift_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -26,7 +26,7 @@ void tank0207_mode_lift_flont(unsigned char gval) {
}
}
void
tank0207_mode_lift_back
(
unsigned
char
gval
)
{
void
tank0207_mode_lift_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_SPEED
,
75
);
...
...
@@ -43,7 +43,7 @@ void tank0207_mode_lift_back(unsigned char gval) {
}
}
void
tank0207_mode_right_flont
(
unsigned
char
gval
)
{
void
tank0207_mode_right_flont
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
...
...
@@ -62,7 +62,7 @@ void tank0207_mode_right_flont(unsigned char gval) {
}
}
void
tank0207_mode_right_back
(
unsigned
char
gval
)
{
void
tank0207_mode_right_back
(
int
gval
)
{
int
b
=
0
;
if
(
gval
<
50
)
{
pwmWrite
(
PWM_PIN_CHANGE
,
75
);
...
...
@@ -110,10 +110,10 @@ int tank0207_change_grading(int mode){
return
mode_val
;
}
void
tank0207_change
(
unsigned
char
*
buf
)
{
unsigned
char
type
=
buf
[
0
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
void
tank0207_change
(
int
*
buf
)
{
int
type
=
buf
[
0
];
int
mode
=
buf
[
1
];
int
val
=
buf
[
2
];
static
int
tank0207_steering_t
=
0
;
static
int
tank0207_front_t
=
0
;
...
...
drivers/devicecontrol/tank0207_control.h
View file @
67dda630
...
...
@@ -3,6 +3,6 @@
void
tank0207_middle
();
void
tank0207_change
(
unsigned
char
*
buf
);
void
tank0207_change
(
int
*
buf
);
#endif
\ No newline at end of file
drivers/devicecontrol/tank_common.c
View file @
67dda630
...
...
@@ -3,7 +3,7 @@
#include "modules_common.h"
#include "gpio_common.h"
int
tank_shot_back_stop
(
unsigned
char
pin
,
unsigned
char
val
);
int
tank_shot_back_stop
(
int
pin
,
int
val
);
const
tank_common_back
*
g_tank_common_config_t
=
NULL
;
...
...
@@ -11,10 +11,10 @@ int g_tank_shot_index=0;//状态机,用于状态机,坦克接收射击倒退
static
bool
s_tank_shot_index_cool
=
1
;
//状态机,用于冷却状态机,坦克接收射击倒退状态机全局变量
/*击打后退速度设置,混空模式下为单路,单独模式下为双路控制,后续需要优化*/
void
tank_shot_back
(
unsigned
char
gval
)
{
void
tank_shot_back
(
int
gval
)
{
int
b
=
0
;
unsigned
char
valt
[
3
]
=
{
0
};
int
valt
[
3
]
=
{
0
};
valt
[
1
]
=
2
;
if
(
gval
==
0
)
valt
[
2
]
=
0
;
else
valt
[
2
]
=
gval
;
...
...
@@ -197,7 +197,7 @@ void tank_shot_pthrpoll_task_init(){
}
/*坦克后退射击*/
int
tank_shot_back_stop
(
unsigned
char
pin
,
unsigned
char
val
){
int
tank_shot_back_stop
(
int
pin
,
int
val
){
if
(
pin
!=
27
){
my_zlog_debug
(
"非27引脚"
);
...
...
@@ -235,7 +235,7 @@ void device_poilthread_close(){
}
/*坦克射击接口,只有在特定设备号下使用*/
void
tank_shot_stop_control
(
int
device_id
,
unsigned
char
pin
,
unsigned
char
val
)
{
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
)
{
// 查找设备配置
...
...
drivers/devicecontrol/tank_common.h
View file @
67dda630
...
...
@@ -8,7 +8,7 @@ typedef struct {
int
back_time
;
int
back_interval_back
;
int
shot_back_speed
;
int
(
*
shot_back
)(
unsigned
char
pin
,
unsigned
char
val
);
int
(
*
shot_back
)(
int
pin
,
int
val
);
}
tank_common_back
;
typedef
enum
{
...
...
@@ -17,7 +17,7 @@ typedef enum {
}
shot_state
;
/*坦克射击接口,只有在特定设备号下使用*/
void
tank_shot_stop_control
(
int
device_id
,
unsigned
char
pin
,
unsigned
char
val
);
void
tank_shot_stop_control
(
int
device_id
,
int
pin
,
int
val
);
/*设置后退的时间重置s*/
void
set_tank_shot_index_cool
(
bool
index
);
...
...
drivers/selfcontrol/self_devicecontrol.c
View file @
67dda630
...
...
@@ -64,7 +64,7 @@ void set_self_control_time_countfuntion(){
void
self_device_control_task
(){
static
int
i
=
0
;
static
unsigned
char
valt
[
3
];
static
int
valt
[
3
];
int
time_now
=
g_self_control_time_count
*
20
;
...
...
include/drivers_common.h
View file @
67dda630
...
...
@@ -6,5 +6,6 @@
#include "ip_reader.h"
#include "sensors_common.h"
#include"self_devicecontrol.h"
#include "steering_control.h"
#endif
\ No newline at end of file
modules/mqtt/mqtt_infor_handle.c
View file @
67dda630
...
...
@@ -15,7 +15,7 @@ int g_devcontrol_exit_count = 0;
int
g_message_type
=
0
;
// 接收的mqtt的g_message_type
static
unsigned
char
g_valt
[
4
];
// 存放mqtt接收的tpye,mode等
static
int
g_valt
[
4
];
// 存放mqtt接收的tpye,mode等
// 心跳发送格式*5/2
void
heartbeat_send
()
...
...
@@ -155,9 +155,9 @@ void message_3(cJSON *body)
cJSON
*
type
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"type"
);
cJSON
*
val
=
cJSON_GetObjectItem
(
pwm_ctrl
,
"val"
);
// val为pwm的值 0~100(unsigned char)(unsigned char)
unsigned
char
modeTemp
=
mode
->
valueint
;
unsigned
char
typeTemp
=
type
->
valueint
;
unsigned
char
valTemp
=
val
->
valueint
;
int
modeTemp
=
mode
->
valueint
;
int
typeTemp
=
type
->
valueint
;
int
valTemp
=
val
->
valueint
;
g_valt
[
0
]
=
typeTemp
;
g_valt
[
1
]
=
modeTemp
;
...
...
@@ -182,8 +182,8 @@ void message_4(cJSON *body)
cJSON
*
pin
=
cJSON_GetObjectItem
(
pin_setctrl
,
"pin"
);
cJSON
*
val
=
cJSON_GetObjectItem
(
pin_setctrl
,
"val"
);
// val为pwm的值 0~100(unsigned char)(unsigned char)
unsigned
char
pinTemp
=
pin
->
valueint
;
unsigned
char
valTemp
=
val
->
valueint
;
int
pinTemp
=
pin
->
valueint
;
int
valTemp
=
val
->
valueint
;
if
(
valTemp
>=
1
)
{
...
...
@@ -265,6 +265,27 @@ void message_4_judyverify(cJSON *body)
}
}
void
message_6_steering_judyverify
(
cJSON
*
body
)
{
if
(
VERIFIED_MODE
==
FALSE
)
{
steering_mqtt_recv
(
body
);
my_zlog_warn
(
"不使用验证"
);
return
;
}
receive_jwt
(
body
);
if
(
g_verify_index
==
0
)
{
steering_mqtt_recv
(
body
);
}
else
{
my_zlog_warn
(
"验证不通过"
);
}
}
// 接收到设备改名函数
int
device_mqttchange_name
(
cJSON
*
device_id
)
{
...
...
@@ -323,6 +344,10 @@ int device_message_receive(cJSON *json)
audio_speaker_init
();
my_zlog_debug
(
"执行麦和喇叭命令"
);
break
;
case
6
:
message_6_steering_judyverify
(
body
);
my_zlog_debug
(
"执行方向盘命令"
);
break
;
case
2001
:
audioplay_mqtt_receive
(
body
);
my_zlog_debug
(
"进入音频播放"
);
...
...
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