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
62ef36cf
Commit
62ef36cf
authored
Jul 24, 2025
by
学习的菜鸟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入了结构体
parent
4d92d557
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
70 additions
and
23 deletions
+70
-23
main
build/main
+0
-0
car0103_control.c
drivers/devicecontrol/car0103_control.c
+1
-1
car0103_control.h
drivers/devicecontrol/car0103_control.h
+2
-1
car0104_control.c
drivers/devicecontrol/car0104_control.c
+1
-1
car0104_control.h
drivers/devicecontrol/car0104_control.h
+2
-1
devcontrol_common.c
drivers/devicecontrol/devcontrol_common.c
+52
-5
tank02002_control.c
drivers/devicecontrol/tank02002_control.c
+1
-1
tank02002_control.h
drivers/devicecontrol/tank02002_control.h
+1
-1
devcontrol_common.h
include/devcontrol_common.h
+8
-0
mqtt_infor_handle.c
modules/mqtt/mqtt_infor_handle.c
+2
-12
No files found.
build/main
View file @
62ef36cf
No preview for this file type
drivers/devicecontrol/car0103_control.c
View file @
62ef36cf
...
@@ -169,7 +169,7 @@ void mode_car0103_right_back(unsigned char gval) {
...
@@ -169,7 +169,7 @@ void mode_car0103_right_back(unsigned char gval) {
}
}
}
}
int
car0103_change
(
unsigned
char
*
buf
)
{
void
car0103_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
unsigned
char
val
=
buf
[
2
];
if
(
mode
==
1
)
{
if
(
mode
==
1
)
{
...
...
drivers/devicecontrol/car0103_control.h
View file @
62ef36cf
...
@@ -3,6 +3,6 @@
...
@@ -3,6 +3,6 @@
void
car0103_middle
();
void
car0103_middle
();
int
car0103_change
(
unsigned
char
*
buf
);
void
car0103_change
(
unsigned
char
*
buf
);
#endif
#endif
\ No newline at end of file
drivers/devicecontrol/car0104_control.c
View file @
62ef36cf
...
@@ -168,7 +168,7 @@ void car0104_lift(unsigned char gval) {
...
@@ -168,7 +168,7 @@ void car0104_lift(unsigned char gval) {
}
}
}
}
int
car0104_change
(
unsigned
char
*
buf
)
{
void
car0104_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
unsigned
char
val
=
buf
[
2
];
...
...
drivers/devicecontrol/car0104_control.h
View file @
62ef36cf
...
@@ -3,6 +3,6 @@
...
@@ -3,6 +3,6 @@
void
car0104_stop
();
void
car0104_stop
();
int
car0104_change
(
unsigned
char
*
buf
);
void
car0104_change
(
unsigned
char
*
buf
);
#endif
#endif
\ No newline at end of file
drivers/devicecontrol/devcontrol_common.c
View file @
62ef36cf
#include "devcontrol_common.h"
#include "devcontrol_common.h"
const
device_didrive
device_didrive_control_config_t
[]
=
{
{
.
device_id
=
DEVICE_CAR0101
,
.
device_didrive_control
=
car0101_control_change
},
{
.
device_id
=
DEVICE_CAR0102
,
.
device_didrive_control
=
car0102_speed_change
},
{
.
device_id
=
DEVICE_CAR0103
,
.
device_didrive_control
=
car0103_change
},
{
.
device_id
=
DEVICE_CAR0104
,
.
device_didrive_control
=
car0104_change
},
{
.
device_id
=
DEVICE_TANK0202
,
.
device_didrive_control
=
tank0202_change
},
{
.
device_id
=
DEVICE_PAO_PTZ0401
,
.
device_didrive_control
=
PTZ_pwm_change
},
// 结束标记
{
.
device_id
=
-
1
}
};
const
device_abnormal_close_t
devcontrol_config_t
[]
=
{
const
device_abnormal_close_t
devcontrol_config_t
[]
=
{
{
{
.
device_id
=
DEVICE_CAR0101
,
.
device_id
=
DEVICE_CAR0101
,
...
@@ -20,7 +49,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
...
@@ -20,7 +49,7 @@ const device_abnormal_close_t devcontrol_config_t[]= {
{
{
.
device_id
=
DEVICE_TANK0202
,
.
device_id
=
DEVICE_TANK0202
,
.
device_abnormal_stop
=
tank0202_middle
,
.
device_abnormal_stop
=
tank0202_middle
,
.
device_close
=
tank0202_thread_close
.
device_close
=
tank0202_thread_close
},
},
{
{
.
device_id
=
DEVICE_PAO_PTZ0401
,
.
device_id
=
DEVICE_PAO_PTZ0401
,
...
@@ -42,14 +71,12 @@ void device_stop(int device_id) {
...
@@ -42,14 +71,12 @@ void device_stop(int device_id) {
}
}
if
(
!
config
)
{
if
(
!
config
)
{
my_zlog_error
(
"Error: Device ID %d not found!
\n
"
,
device_id
);
my_zlog_error
(
"Error: Device
stop
ID %d not found!
\n
"
,
device_id
);
return
;
return
;
}
}
config
->
device_abnormal_stop
();
// 速度控制初始化
config
->
device_abnormal_stop
();
// 速度控制初始化
my_zlog_debug
(
"device stop successfully!,:%d"
,
device_id
);
}
}
void
device_end_close
(
int
device_id
)
{
void
device_end_close
(
int
device_id
)
{
...
@@ -64,7 +91,7 @@ void device_end_close(int device_id) {
...
@@ -64,7 +91,7 @@ void device_end_close(int device_id) {
}
}
if
(
!
config
)
{
if
(
!
config
)
{
my_zlog_error
(
"
device close and end successfully!,:%d"
,
device_id
);
my_zlog_error
(
"
Error: Device close ID %d not found!
\n
"
,
device_id
);
return
;
return
;
}
}
...
@@ -72,3 +99,23 @@ void device_end_close(int device_id) {
...
@@ -72,3 +99,23 @@ void device_end_close(int device_id) {
}
}
void
device_walk_control
(
int
device_id
,
unsigned
char
*
valt
)
{
const
device_didrive
*
config
=
NULL
;
// 查找设备配置
for
(
int
i
=
0
;
device_didrive_control_config_t
[
i
].
device_id
!=
-
1
;
i
++
)
{
if
(
device_didrive_control_config_t
[
i
].
device_id
==
device_id
)
{
config
=
&
device_didrive_control_config_t
[
i
];
break
;
}
}
if
(
!
config
)
{
my_zlog_error
(
"Error: Device close ID %d not found!
\n
"
,
device_id
);
return
;
}
config
->
device_didrive_control
(
valt
);
// 速度控制初始化
}
drivers/devicecontrol/tank02002_control.c
View file @
62ef36cf
...
@@ -170,7 +170,7 @@ void mode_right_back(unsigned char gval) {
...
@@ -170,7 +170,7 @@ void mode_right_back(unsigned char gval) {
}
}
}
}
int
tank0202_change
(
unsigned
char
*
buf
)
{
void
tank0202_change
(
unsigned
char
*
buf
)
{
unsigned
char
mode
=
buf
[
1
];
unsigned
char
mode
=
buf
[
1
];
unsigned
char
val
=
buf
[
2
];
unsigned
char
val
=
buf
[
2
];
...
...
drivers/devicecontrol/tank02002_control.h
View file @
62ef36cf
...
@@ -7,7 +7,7 @@ void tank0202_middle();
...
@@ -7,7 +7,7 @@ void tank0202_middle();
void
tank_shot_back_stop_task_end
();
void
tank_shot_back_stop_task_end
();
int
tank0202_change
(
unsigned
char
*
buf
);
void
tank0202_change
(
unsigned
char
*
buf
);
int
tank_shot_back_stop
(
int
pin
,
int
val
);
int
tank_shot_back_stop
(
int
pin
,
int
val
);
...
...
include/devcontrol_common.h
View file @
62ef36cf
...
@@ -16,6 +16,11 @@ typedef struct {
...
@@ -16,6 +16,11 @@ typedef struct {
void
(
*
device_close
)(
void
);
// 速度控制函数指针
void
(
*
device_close
)(
void
);
// 速度控制函数指针
}
device_abnormal_close_t
;
}
device_abnormal_close_t
;
typedef
struct
{
int
device_id
;
// 设备ID (101, 102等)
void
(
*
device_didrive_control
)(
unsigned
char
*
valt
);
// PWM初始化函数指针
}
device_didrive
;
#define DEVICE_CAR0101 101
#define DEVICE_CAR0101 101
#define DEVICE_CAR0102 102
#define DEVICE_CAR0102 102
#define DEVICE_CAR0103 103
#define DEVICE_CAR0103 103
...
@@ -28,4 +33,6 @@ void device_stop(int device_id);
...
@@ -28,4 +33,6 @@ void device_stop(int device_id);
void
device_end_close
(
int
device_id
);
void
device_end_close
(
int
device_id
);
void
device_walk_control
(
int
device_id
,
unsigned
char
*
valt
);
#endif
#endif
\ No newline at end of file
modules/mqtt/mqtt_infor_handle.c
View file @
62ef36cf
...
@@ -80,16 +80,6 @@ void heartbeat_send() {
...
@@ -80,16 +80,6 @@ void heartbeat_send() {
cJSON_Delete
(
root
);
// 释放 cJSON 对象
cJSON_Delete
(
root
);
// 释放 cJSON 对象
}
}
//mqtt设备行走驱动函数
void
device_driver
(){
if
(
g_device_type
==
DEVICE_CAR0101
)
car0101_control_change
(
g_valt
)
;
if
(
g_device_type
==
DEVICE_CAR0102
)
car0102_speed_change
(
g_valt
)
;
if
(
g_device_type
==
DEVICE_CAR0103
)
car0103_change
(
g_valt
)
;
if
(
g_device_type
==
DEVICE_CAR0104
)
car0104_change
(
g_valt
)
;
if
(
g_device_type
==
DEVICE_TANK0202
)
tank0202_change
(
g_valt
);
if
(
g_device_type
==
DEVICE_PAO_PTZ0401
)
PTZ_pwm_change
(
g_valt
);
}
//角度发送
//角度发送
void
angle_mqtt_send
()
{
void
angle_mqtt_send
()
{
float
angle_shot
=
ads1115_read_channel
(
2
);
float
angle_shot
=
ads1115_read_channel
(
2
);
...
@@ -144,7 +134,7 @@ void message_3(cJSON *body){
...
@@ -144,7 +134,7 @@ void message_3(cJSON *body){
my_zlog_debug
(
"modeTemp:%d"
,
g_valt
[
1
]);
my_zlog_debug
(
"modeTemp:%d"
,
g_valt
[
1
]);
my_zlog_debug
(
"valTemp:%d"
,
g_valt
[
2
]);
my_zlog_debug
(
"valTemp:%d"
,
g_valt
[
2
]);
device_
driver
(
);
device_
walk_control
(
g_device_type
,
g_valt
);
}
}
...
@@ -175,7 +165,7 @@ void message_4(cJSON *body){//message 为4时候
...
@@ -175,7 +165,7 @@ void message_4(cJSON *body){//message 为4时候
pin_value
(
g_valt
[
1
],
g_valt
[
2
]);
pin_value
(
g_valt
[
1
],
g_valt
[
2
]);
pwm_value
(
g_valt
[
1
],
g_valt
[
2
]);
pwm_value
(
g_valt
[
1
],
g_valt
[
2
]);
//if(AppExit_pin_pwm ==
202 ) tank_shot_back_stop(g_valt[1],g_valt[2]);
if
(
g_device_type
==
DEVICE_TANK0
202
)
tank_shot_back_stop
(
g_valt
[
1
],
g_valt
[
2
]);
}
}
//当接收到2时候验证
//当接收到2时候验证
...
...
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