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
22393bcf
Commit
22393bcf
authored
Jan 26, 2026
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加入了可以坐人的大车
parent
3e4f19d9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
139 additions
and
49 deletions
+139
-49
device_identity.c
app/device_identity/device_identity.c
+4
-0
device_identity.h
app/device_identity/device_identity.h
+1
-0
pthread_open.c
app/main/pthread_open.c
+1
-2
Makefile
build/Makefile
+27
-0
main
build/main
+0
-0
progress.marks
build/third_party/mosquitto/apps/CMakeFiles/progress.marks
+1
-1
progress.make
...osquitto_ctrl/CMakeFiles/mosquitto_ctrl.dir/progress.make
+2
-2
progress.make
...itto_passwd/CMakeFiles/mosquitto_passwd.dir/progress.make
+1
-1
progress.marks
...mosquitto/apps/mosquitto_passwd/CMakeFiles/progress.marks
+1
-1
progress.make
...itto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
+6
-6
progress.marks
...d/third_party/mosquitto/plugins/CMakeFiles/progress.marks
+1
-1
progress.make
.../CMakeFiles/mosquitto_message_timestamp.dir/progress.make
+1
-1
progress.marks
...uitto/plugins/message-timestamp/CMakeFiles/progress.marks
+1
-1
progress.make
...arty/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
+16
-16
car0105_control.c
drivers/devicecontrol/car0105_control.c
+0
-0
car0105_control.h
drivers/devicecontrol/car0105_control.h
+13
-0
devcontrol_common.c
drivers/devicecontrol/devcontrol_common.c
+25
-1
devcontrol_common.h
drivers/devicecontrol/devcontrol_common.h
+5
-0
pg0403_serial.c
drivers/devicecontrol/pg0403_serial.c
+6
-8
pg0403_serial.h
drivers/devicecontrol/pg0403_serial.h
+0
-7
device_init.c
drivers/gpio/device_init.c
+11
-0
gpio_control.c
drivers/gpio/gpio_control.c
+7
-1
fcsgdevintroduce.md
fcsgdevintroduce.md
+1
-0
common.h
include/common.h
+8
-0
No files found.
app/device_identity/device_identity.c
View file @
22393bcf
...
@@ -91,6 +91,7 @@ int hash_insert_init(HashTable_t *HashTable_t) {
...
@@ -91,6 +91,7 @@ int hash_insert_init(HashTable_t *HashTable_t) {
insert
(
HashTable_t
,
"0102"
,
CAR_0102
);
insert
(
HashTable_t
,
"0102"
,
CAR_0102
);
insert
(
HashTable_t
,
"0103"
,
CAR_0103
);
insert
(
HashTable_t
,
"0103"
,
CAR_0103
);
insert
(
HashTable_t
,
"0104"
,
CAR_0104
);
insert
(
HashTable_t
,
"0104"
,
CAR_0104
);
insert
(
HashTable_t
,
"0105"
,
CAR_0105
);
insert
(
HashTable_t
,
"0201"
,
TANK_0201
);
insert
(
HashTable_t
,
"0201"
,
TANK_0201
);
insert
(
HashTable_t
,
"0202"
,
TANK_0202
);
insert
(
HashTable_t
,
"0202"
,
TANK_0202
);
insert
(
HashTable_t
,
"0203"
,
TANK_0203
);
insert
(
HashTable_t
,
"0203"
,
TANK_0203
);
...
@@ -116,6 +117,9 @@ int device_judg(CodeEnum_t code,char *sub_str) {
...
@@ -116,6 +117,9 @@ int device_judg(CodeEnum_t code,char *sub_str) {
}
else
if
(
code
==
CAR_0104
)
{
}
else
if
(
code
==
CAR_0104
)
{
device_init
(
DEVICE_CAR0104
);
device_init
(
DEVICE_CAR0104
);
my_zlog_info
(
"使用推土机,使用型号%s"
,
sub_str
);
my_zlog_info
(
"使用推土机,使用型号%s"
,
sub_str
);
}
if
(
code
==
CAR_0105
)
{
device_init
(
DEVICE_CAR0105
);
my_zlog_info
(
"使用人坐超大车,型号%s"
,
sub_str
);
}
else
if
(
code
==
TANK_0202
)
{
}
else
if
(
code
==
TANK_0202
)
{
device_init
(
DEVICE_TANK0202
);
device_init
(
DEVICE_TANK0202
);
my_zlog_info
(
"使用型号%s"
,
sub_str
);
my_zlog_info
(
"使用型号%s"
,
sub_str
);
...
...
app/device_identity/device_identity.h
View file @
22393bcf
...
@@ -12,6 +12,7 @@ typedef enum {
...
@@ -12,6 +12,7 @@ typedef enum {
CAR_0102
,
CAR_0102
,
CAR_0103
,
CAR_0103
,
CAR_0104
,
CAR_0104
,
CAR_0105
,
TANK_0201
,
TANK_0201
,
TANK_0202
,
TANK_0202
,
TANK_0203
,
TANK_0203
,
...
...
app/main/pthread_open.c
View file @
22393bcf
...
@@ -42,10 +42,9 @@ int thread_start_init(ThreadFunc thread_exit_time, ThreadFunc thread_mqtt_beat,
...
@@ -42,10 +42,9 @@ int thread_start_init(ThreadFunc thread_exit_time, ThreadFunc thread_mqtt_beat,
// 出现意外自动停止
// 出现意外自动停止
void
*
thread_exit_time
(
void
*
arg
)
void
*
thread_exit_time
(
void
*
arg
)
{
{
pg0403_serial_run
();
device_serial_exit_run
();
//串口设备的异常退出和接收运行
while
(
1
)
while
(
1
)
{
{
if
(
get_self_control_index
()
==
false
)
if
(
get_self_control_index
()
==
false
)
{
{
...
...
build/Makefile
View file @
22393bcf
...
@@ -617,6 +617,30 @@ drivers/devicecontrol/car0104_control.c.s:
...
@@ -617,6 +617,30 @@ drivers/devicecontrol/car0104_control.c.s:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/car0104_control.c.s
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/car0104_control.c.s
.PHONY
:
drivers/devicecontrol/car0104_control.c.s
.PHONY
:
drivers/devicecontrol/car0104_control.c.s
drivers/devicecontrol/car0105_control.o
:
drivers/devicecontrol/car0105_control.c.o
.PHONY
:
drivers/devicecontrol/car0105_control.o
# target to build an object file
drivers/devicecontrol/car0105_control.c.o
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/car0105_control.c.o
.PHONY
:
drivers/devicecontrol/car0105_control.c.o
drivers/devicecontrol/car0105_control.i
:
drivers/devicecontrol/car0105_control.c.i
.PHONY
:
drivers/devicecontrol/car0105_control.i
# target to preprocess a source file
drivers/devicecontrol/car0105_control.c.i
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/car0105_control.c.i
.PHONY
:
drivers/devicecontrol/car0105_control.c.i
drivers/devicecontrol/car0105_control.s
:
drivers/devicecontrol/car0105_control.c.s
.PHONY
:
drivers/devicecontrol/car0105_control.s
# target to generate assembly for a file
drivers/devicecontrol/car0105_control.c.s
:
$(MAKE)
$(MAKESILENT)
-f
CMakeFiles/main.dir/build.make CMakeFiles/main.dir/drivers/devicecontrol/car0105_control.c.s
.PHONY
:
drivers/devicecontrol/car0105_control.c.s
drivers/devicecontrol/devcontrol_common.o
:
drivers/devicecontrol/devcontrol_common.c.o
drivers/devicecontrol/devcontrol_common.o
:
drivers/devicecontrol/devcontrol_common.c.o
.PHONY
:
drivers/devicecontrol/devcontrol_common.o
.PHONY
:
drivers/devicecontrol/devcontrol_common.o
...
@@ -2069,6 +2093,9 @@ help:
...
@@ -2069,6 +2093,9 @@ help:
@
echo
"... drivers/devicecontrol/car0104_control.o"
@
echo
"... drivers/devicecontrol/car0104_control.o"
@
echo
"... drivers/devicecontrol/car0104_control.i"
@
echo
"... drivers/devicecontrol/car0104_control.i"
@
echo
"... drivers/devicecontrol/car0104_control.s"
@
echo
"... drivers/devicecontrol/car0104_control.s"
@
echo
"... drivers/devicecontrol/car0105_control.o"
@
echo
"... drivers/devicecontrol/car0105_control.i"
@
echo
"... drivers/devicecontrol/car0105_control.s"
@
echo
"... drivers/devicecontrol/devcontrol_common.o"
@
echo
"... drivers/devicecontrol/devcontrol_common.o"
@
echo
"... drivers/devicecontrol/devcontrol_common.i"
@
echo
"... drivers/devicecontrol/devcontrol_common.i"
@
echo
"... drivers/devicecontrol/devcontrol_common.s"
@
echo
"... drivers/devicecontrol/devcontrol_common.s"
...
...
build/main
View file @
22393bcf
No preview for this file type
build/third_party/mosquitto/apps/CMakeFiles/progress.marks
View file @
22393bcf
2
3
2
2
build/third_party/mosquitto/apps/mosquitto_ctrl/CMakeFiles/mosquitto_ctrl.dir/progress.make
View file @
22393bcf
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_1
=
81
CMAKE_PROGRESS_2
=
81
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_3
=
CMAKE_PROGRESS_4
=
82
CMAKE_PROGRESS_4
=
82
CMAKE_PROGRESS_5
=
CMAKE_PROGRESS_5
=
...
...
build/third_party/mosquitto/apps/mosquitto_passwd/CMakeFiles/mosquitto_passwd.dir/progress.make
View file @
22393bcf
CMAKE_PROGRESS_1
=
90
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_3
=
91
CMAKE_PROGRESS_3
=
91
CMAKE_PROGRESS_4
=
CMAKE_PROGRESS_4
=
...
...
build/third_party/mosquitto/apps/mosquitto_passwd/CMakeFiles/progress.marks
View file @
22393bcf
3
2
build/third_party/mosquitto/lib/CMakeFiles/libmosquitto_static.dir/progress.make
View file @
22393bcf
...
@@ -8,8 +8,8 @@ CMAKE_PROGRESS_7 =
...
@@ -8,8 +8,8 @@ CMAKE_PROGRESS_7 =
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_8
=
CMAKE_PROGRESS_9
=
18
CMAKE_PROGRESS_9
=
18
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_10
=
CMAKE_PROGRESS_11
=
19
CMAKE_PROGRESS_11
=
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_12
=
19
CMAKE_PROGRESS_13
=
CMAKE_PROGRESS_13
=
CMAKE_PROGRESS_14
=
20
CMAKE_PROGRESS_14
=
20
CMAKE_PROGRESS_15
=
CMAKE_PROGRESS_15
=
...
@@ -34,11 +34,11 @@ CMAKE_PROGRESS_33 =
...
@@ -34,11 +34,11 @@ CMAKE_PROGRESS_33 =
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_34
=
CMAKE_PROGRESS_35
=
27
CMAKE_PROGRESS_35
=
27
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_36
=
CMAKE_PROGRESS_37
=
28
CMAKE_PROGRESS_37
=
CMAKE_PROGRESS_38
=
CMAKE_PROGRESS_38
=
28
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_39
=
CMAKE_PROGRESS_40
=
29
CMAKE_PROGRESS_40
=
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_41
=
29
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_42
=
CMAKE_PROGRESS_43
=
30
CMAKE_PROGRESS_43
=
30
CMAKE_PROGRESS_44
=
CMAKE_PROGRESS_44
=
...
...
build/third_party/mosquitto/plugins/CMakeFiles/progress.marks
View file @
22393bcf
5
6
build/third_party/mosquitto/plugins/message-timestamp/CMakeFiles/mosquitto_message_timestamp.dir/progress.make
View file @
22393bcf
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_1
=
CMAKE_PROGRESS_2
=
CMAKE_PROGRESS_2
=
90
build/third_party/mosquitto/plugins/message-timestamp/CMakeFiles/progress.marks
View file @
22393bcf
0
1
build/third_party/mosquitto/src/CMakeFiles/mosquitto.dir/progress.make
View file @
22393bcf
...
@@ -12,17 +12,17 @@ CMAKE_PROGRESS_11 =
...
@@ -12,17 +12,17 @@ CMAKE_PROGRESS_11 =
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_12
=
CMAKE_PROGRESS_13
=
59
CMAKE_PROGRESS_13
=
59
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_14
=
CMAKE_PROGRESS_15
=
CMAKE_PROGRESS_15
=
60
CMAKE_PROGRESS_16
=
60
CMAKE_PROGRESS_16
=
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_17
=
CMAKE_PROGRESS_18
=
CMAKE_PROGRESS_18
=
61
CMAKE_PROGRESS_19
=
61
CMAKE_PROGRESS_19
=
CMAKE_PROGRESS_20
=
CMAKE_PROGRESS_20
=
CMAKE_PROGRESS_21
=
CMAKE_PROGRESS_21
=
62
CMAKE_PROGRESS_22
=
62
CMAKE_PROGRESS_22
=
CMAKE_PROGRESS_23
=
CMAKE_PROGRESS_23
=
CMAKE_PROGRESS_24
=
CMAKE_PROGRESS_24
=
63
CMAKE_PROGRESS_25
=
63
CMAKE_PROGRESS_25
=
CMAKE_PROGRESS_26
=
CMAKE_PROGRESS_26
=
CMAKE_PROGRESS_27
=
64
CMAKE_PROGRESS_27
=
64
CMAKE_PROGRESS_28
=
CMAKE_PROGRESS_28
=
...
@@ -41,14 +41,14 @@ CMAKE_PROGRESS_40 =
...
@@ -41,14 +41,14 @@ CMAKE_PROGRESS_40 =
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_41
=
CMAKE_PROGRESS_42
=
69
CMAKE_PROGRESS_42
=
69
CMAKE_PROGRESS_43
=
CMAKE_PROGRESS_43
=
CMAKE_PROGRESS_44
=
CMAKE_PROGRESS_44
=
70
CMAKE_PROGRESS_45
=
70
CMAKE_PROGRESS_45
=
CMAKE_PROGRESS_46
=
CMAKE_PROGRESS_46
=
CMAKE_PROGRESS_47
=
CMAKE_PROGRESS_47
=
71
CMAKE_PROGRESS_48
=
71
CMAKE_PROGRESS_48
=
CMAKE_PROGRESS_49
=
CMAKE_PROGRESS_49
=
CMAKE_PROGRESS_50
=
CMAKE_PROGRESS_50
=
72
CMAKE_PROGRESS_51
=
72
CMAKE_PROGRESS_51
=
CMAKE_PROGRESS_52
=
CMAKE_PROGRESS_52
=
CMAKE_PROGRESS_53
=
73
CMAKE_PROGRESS_53
=
73
CMAKE_PROGRESS_54
=
CMAKE_PROGRESS_54
=
...
@@ -70,7 +70,7 @@ CMAKE_PROGRESS_69 =
...
@@ -70,7 +70,7 @@ CMAKE_PROGRESS_69 =
CMAKE_PROGRESS_70
=
CMAKE_PROGRESS_70
=
CMAKE_PROGRESS_71
=
79
CMAKE_PROGRESS_71
=
79
CMAKE_PROGRESS_72
=
CMAKE_PROGRESS_72
=
CMAKE_PROGRESS_73
=
CMAKE_PROGRESS_73
=
80
CMAKE_PROGRESS_74
=
80
CMAKE_PROGRESS_74
=
CMAKE_PROGRESS_75
=
CMAKE_PROGRESS_75
=
drivers/devicecontrol/car0105_control.c
0 → 100644
View file @
22393bcf
This diff is collapsed.
Click to expand it.
drivers/devicecontrol/car0105_control.h
0 → 100644
View file @
22393bcf
#ifndef CAR0105_CONTROL_H
#define CAR0105_CONTROL_H
int
car0105_serial_run
();
void
car0105_control_change
(
unsigned
char
*
buf
);
void
car0105_serial_stop
();
#endif
\ No newline at end of file
drivers/devicecontrol/devcontrol_common.c
View file @
22393bcf
...
@@ -20,6 +20,10 @@ const device_didrive device_didrive_control_config_t[]={
...
@@ -20,6 +20,10 @@ const device_didrive device_didrive_control_config_t[]={
.
device_didrive_control
=
car0104_change
.
device_didrive_control
=
car0104_change
},
},
{
{
.
device_id
=
DEVICE_CAR0105
,
.
device_didrive_control
=
car0105_control_change
},
{
.
device_id
=
DEVICE_TANK0202
,
.
device_id
=
DEVICE_TANK0202
,
.
device_didrive_control
=
tank0202_change
.
device_didrive_control
=
tank0202_change
},
},
...
@@ -86,6 +90,14 @@ const device_abnormal_close_t devcontrol_config_t[]= {
...
@@ -86,6 +90,14 @@ const device_abnormal_close_t devcontrol_config_t[]= {
},
},
{
{
.
device_id
=
DEVICE_CAR0105
,
.
device_abnormal_stop
=
car0105_serial_stop
,
.
device_close
=
NULL
,
// TANK0206没有单独的关闭函数
.
gpio_pin_pulled
=
pin_all_default
,
.
gpio_pwm_pulled
=
pwm_all_default
},
{
.
device_id
=
DEVICE_TANK0202
,
.
device_id
=
DEVICE_TANK0202
,
.
device_abnormal_stop
=
tank0202_middle
,
.
device_abnormal_stop
=
tank0202_middle
,
.
device_close
=
device_poilthread_close
,
.
device_close
=
device_poilthread_close
,
...
@@ -164,7 +176,7 @@ void device_stop(int device_id) {
...
@@ -164,7 +176,7 @@ void device_stop(int device_id) {
}
}
if
(
!
config
)
{
if
(
!
config
)
{
my_zlog_error
(
"Error: Device gpio stop ID %d not found!"
,
device_id
);
my_zlog_error
(
"Error: Device gpio stop
is low
ID %d not found!"
,
device_id
);
return
;
return
;
}
}
...
@@ -217,3 +229,14 @@ void device_walk_control(int device_id,unsigned char *valt) {
...
@@ -217,3 +229,14 @@ void device_walk_control(int device_id,unsigned char *valt) {
config
->
device_didrive_control
(
valt
);
// 速度控制初始化
config
->
device_didrive_control
(
valt
);
// 速度控制初始化
}
}
/*
* 串口设备启动
*/
void
device_serial_exit_run
(){
if
(
g_device_type
==
DEVICE_CAR0105
){
car0105_serial_run
();
}
else
if
(
g_device_type
==
DEVICE_PG_GPS0403
){
pg0403_serial_run
();
}
else
return
;
}
\ No newline at end of file
drivers/devicecontrol/devcontrol_common.h
View file @
22393bcf
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include "car0102_control.h"
#include "car0102_control.h"
#include "car0103_control.h"
#include "car0103_control.h"
#include "car0104_control.h"
#include "car0104_control.h"
#include "car0105_control.h"
#include "ptz0401_control.h"
#include "ptz0401_control.h"
#include "tank0202_control.h"
#include "tank0202_control.h"
#include "tank0203_control.h"
#include "tank0203_control.h"
...
@@ -22,6 +23,7 @@
...
@@ -22,6 +23,7 @@
#define DEVICE_CAR0102 102 //莽牛小车
#define DEVICE_CAR0102 102 //莽牛小车
#define DEVICE_CAR0103 103 //推土机
#define DEVICE_CAR0103 103 //推土机
#define DEVICE_CAR0104 104 //挖机
#define DEVICE_CAR0104 104 //挖机
#define DEVICE_CAR0105 105 //做人超大车
#define DEVICE_TANK0201 201 //废弃坦克
#define DEVICE_TANK0201 201 //废弃坦克
#define DEVICE_TANK0202 202 //
#define DEVICE_TANK0202 202 //
#define DEVICE_TANK0203 203 //M1A2美国坦克
#define DEVICE_TANK0203 203 //M1A2美国坦克
...
@@ -64,4 +66,6 @@ void device_end_close(int device_id);
...
@@ -64,4 +66,6 @@ void device_end_close(int device_id);
void
device_walk_control
(
int
device_id
,
unsigned
char
*
valt
);
void
device_walk_control
(
int
device_id
,
unsigned
char
*
valt
);
void
device_serial_exit_run
();
#endif
#endif
\ No newline at end of file
drivers/devicecontrol/pg0403_serial.c
View file @
22393bcf
...
@@ -52,7 +52,7 @@ float run_kalman(Kalman1D *k, float measurement) {
...
@@ -52,7 +52,7 @@ float run_kalman(Kalman1D *k, float measurement) {
// 辅助函数:将整数波特率转换为 termios 定义的 speed_t
// 辅助函数:将整数波特率转换为 termios 定义的 speed_t
speed_t
get_baud_rate
(
int
baud_rate
)
{
s
tatic
s
peed_t
get_baud_rate
(
int
baud_rate
)
{
switch
(
baud_rate
)
{
switch
(
baud_rate
)
{
case
9600
:
return
B9600
;
case
9600
:
return
B9600
;
case
19200
:
return
B19200
;
case
19200
:
return
B19200
;
...
@@ -70,7 +70,7 @@ speed_t get_baud_rate(int baud_rate) {
...
@@ -70,7 +70,7 @@ speed_t get_baud_rate(int baud_rate) {
* 打开串口
* 打开串口
* 对应原 C++: bool SerialPort::open(speed_t baud_rate)
* 对应原 C++: bool SerialPort::open(speed_t baud_rate)
*/
*/
int
serial_open
(
SerialPort
*
sp
,
const
char
*
port_name
,
int
baud_rate
)
{
static
int
serial_open
(
SerialPort
*
sp
,
const
char
*
port_name
,
int
baud_rate
)
{
if
(
sp
->
is_open
)
{
if
(
sp
->
is_open
)
{
fprintf
(
stderr
,
"Warning: Port %s is already open.
\n
"
,
sp
->
port_name
);
fprintf
(
stderr
,
"Warning: Port %s is already open.
\n
"
,
sp
->
port_name
);
return
1
;
// 视为成功
return
1
;
// 视为成功
...
@@ -152,7 +152,7 @@ int serial_open(SerialPort *sp, const char *port_name, int baud_rate) {
...
@@ -152,7 +152,7 @@ int serial_open(SerialPort *sp, const char *port_name, int baud_rate) {
* 发送数据
* 发送数据
* C语言中通常使用 write
* C语言中通常使用 write
*/
*/
int
serial_send
(
SerialPort
*
sp
,
uint8_t
*
data
,
int
len
)
{
static
int
serial_send
(
SerialPort
*
sp
,
uint8_t
*
data
,
int
len
)
{
if
(
!
sp
->
is_open
)
{
if
(
!
sp
->
is_open
)
{
my_zlog_error
(
"Error: Port not open."
);
my_zlog_error
(
"Error: Port not open."
);
return
-
1
;
return
-
1
;
...
@@ -169,7 +169,7 @@ int serial_send(SerialPort *sp, uint8_t *data, int len) {
...
@@ -169,7 +169,7 @@ int serial_send(SerialPort *sp, uint8_t *data, int len) {
* 关闭串口
* 关闭串口
* 对应原 C++: void SerialPort::close()
* 对应原 C++: void SerialPort::close()
*/
*/
void
serial_close
(
SerialPort
*
sp
)
{
static
void
serial_close
(
SerialPort
*
sp
)
{
// 原代码中有 stopListening(); C语言中如果没有线程需要手动停止,这里省略
// 原代码中有 stopListening(); C语言中如果没有线程需要手动停止,这里省略
if
(
sp
->
is_open
)
{
if
(
sp
->
is_open
)
{
...
@@ -181,7 +181,7 @@ void serial_close(SerialPort *sp) {
...
@@ -181,7 +181,7 @@ void serial_close(SerialPort *sp) {
}
}
// 初始化结构体
// 初始化结构体
void
serial_init
(
SerialPort
*
sp
)
{
static
void
serial_init
(
SerialPort
*
sp
)
{
sp
->
fd
=
-
1
;
sp
->
fd
=
-
1
;
sp
->
is_open
=
0
;
sp
->
is_open
=
0
;
memset
(
sp
->
port_name
,
0
,
sizeof
(
sp
->
port_name
));
memset
(
sp
->
port_name
,
0
,
sizeof
(
sp
->
port_name
));
...
@@ -213,7 +213,7 @@ int pg0403_serial_init_send(){
...
@@ -213,7 +213,7 @@ int pg0403_serial_init_send(){
* @param buffer: 接收数据的缓冲区
* @param buffer: 接收数据的缓冲区
* @param len: 接收到的数据长度
* @param len: 接收到的数据长度
*/
*/
void
process_serial_data
(
const
uint8_t
*
buffer
,
int
len
)
{
static
void
process_serial_data
(
const
uint8_t
*
buffer
,
int
len
)
{
// 1. 基础长度检查
// 1. 基础长度检查
if
(
len
<
17
)
{
if
(
len
<
17
)
{
return
;
return
;
...
@@ -326,7 +326,6 @@ int pg0403_serial_run(){
...
@@ -326,7 +326,6 @@ int pg0403_serial_run(){
uint8_t
rx_buffer
[
1024
];
uint8_t
rx_buffer
[
1024
];
int
total_bytes
=
0
;
int
total_bytes
=
0
;
if
(
g_device_type
==
DEVICE_PG_GPS0403
){
my_zlog_info
(
"设备为串口打开设备"
);
my_zlog_info
(
"设备为串口打开设备"
);
init_filters
();
init_filters
();
if
(
pg0403_serial_init_send
()
==
0
){
if
(
pg0403_serial_init_send
()
==
0
){
...
@@ -336,7 +335,6 @@ int pg0403_serial_run(){
...
@@ -336,7 +335,6 @@ int pg0403_serial_run(){
pg0403_serial_init_close
();
pg0403_serial_init_close
();
return
-
1
;
return
-
1
;
}
}
}
else
return
-
1
;
while
(
1
){
while
(
1
){
static
int
send_mqtt_count
=
0
;
static
int
send_mqtt_count
=
0
;
int
n
=
read
(
pg_serial
.
fd
,
rx_buffer
,
sizeof
(
rx_buffer
));
int
n
=
read
(
pg_serial
.
fd
,
rx_buffer
,
sizeof
(
rx_buffer
));
...
...
drivers/devicecontrol/pg0403_serial.h
View file @
22393bcf
...
@@ -10,13 +10,6 @@
...
@@ -10,13 +10,6 @@
#define KALMAN_R 0.01f
#define KALMAN_R 0.01f
#define KALMAN_Q 0.01f
#define KALMAN_Q 0.01f
// 定义一个结构体表示串口,整洁
typedef
struct
{
int
fd
;
char
port_name
[
64
];
int
is_open
;
}
SerialPort
;
// 单个维度的卡尔曼状态
// 单个维度的卡尔曼状态
typedef
struct
{
typedef
struct
{
float
estimate
;
// 当前的最优估计值
float
estimate
;
// 当前的最优估计值
...
...
drivers/gpio/device_init.c
View file @
22393bcf
...
@@ -52,6 +52,17 @@ const deviceconfig_t device_configs[] = {
...
@@ -52,6 +52,17 @@ const deviceconfig_t device_configs[] = {
.
device_control_stop
=
car0104_stop
,
/* 补充速度控制函数 */
.
device_control_stop
=
car0104_stop
,
/* 补充速度控制函数 */
.
emergency_code
=
104
.
emergency_code
=
104
},
},
// car0105配置(根据您的需求补充)
{
.
device_id
=
DEVICE_CAR0105
,
.
device_name
=
"car0105"
,
.
gpio_pins
=
{
5
,
6
,
7
,
9
,
10
,
16
,
20
,
22
,
23
,
24
,
25
,
26
,
-
1
},
/* 补充GPIO引脚 */
.
gpio_pwms
=
{
27
,
-
1
},
.
gpio_inputs
=
{
-
1
},
.
device_pwm_init
=
physics_pwm_init
,
.
device_control_stop
=
car0101_middle_pwm
,
/* 补充速度控制函数 */
.
emergency_code
=
105
},
// tank0202配置(根据您的需求补充)
// tank0202配置(根据您的需求补充)
{
{
.
device_id
=
DEVICE_TANK0202
,
.
device_id
=
DEVICE_TANK0202
,
...
...
drivers/gpio/gpio_control.c
View file @
22393bcf
...
@@ -238,6 +238,12 @@ const gpiocontrol_t gpio_configs[] = {
...
@@ -238,6 +238,12 @@ const gpiocontrol_t gpio_configs[] = {
.
device_pwm_value
=
public_pwm_value
.
device_pwm_value
=
public_pwm_value
},
},
{
{
.
device_id
=
DEVICE_CAR0105
,
.
category_id
=
LAND_CAR
,
.
device_pin_value
=
public_pin_value
,
.
device_pwm_value
=
public_pwm_value
},
{
.
device_id
=
DEVICE_TANK0202
,
.
device_id
=
DEVICE_TANK0202
,
.
category_id
=
MARINE_TANK
,
.
category_id
=
MARINE_TANK
,
.
device_pin_value
=
public_pin_value
,
.
device_pin_value
=
public_pin_value
,
...
@@ -314,7 +320,7 @@ void device_gpio_control(int device_id,int pin,int val) {
...
@@ -314,7 +320,7 @@ void device_gpio_control(int device_id,int pin,int val) {
}
}
if
(
!
gpio_control_config_t
)
{
if
(
!
gpio_control_config_t
)
{
my_zlog_error
(
"Error: Device gpio
stop
ID %d not found!"
,
device_id
);
my_zlog_error
(
"Error: Device gpio
control
ID %d not found!"
,
device_id
);
return
;
return
;
}
}
...
...
fcsgdevintroduce.md
View file @
22393bcf
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
-
car0102 为小车 最大速度为200
-
car0102 为小车 最大速度为200
-
car0103 为挖机 最大速度为200,更据电池电压具体调速。原电池为7.6v,大概为140左右
-
car0103 为挖机 最大速度为200,更据电池电压具体调速。原电池为7.6v,大概为140左右
-
car0104 为推土机 最大速度为200,更据电池电压具体调速。原电池为7.6v,大概为140左右
-
car0104 为推土机 最大速度为200,更据电池电压具体调速。原电池为7.6v,大概为140左右
-
car0105 为超大车,改遥控器,很多都没有
-
ptz0401 为炮台,有限位。
-
ptz0401 为炮台,有限位。
-
0403 为定位设备
-
0403 为定位设备
-
0501 为机械狗
-
0501 为机械狗
...
...
include/common.h
View file @
22393bcf
...
@@ -47,4 +47,11 @@
...
@@ -47,4 +47,11 @@
#include "delay.h"
#include "delay.h"
#include "mylog.h"
#include "mylog.h"
// 定义一个结构体表示串口,整洁
typedef
struct
{
int
fd
;
char
port_name
[
64
];
int
is_open
;
}
SerialPort
;
#endif // COMMON_H
#endif // COMMON_H
\ No newline at end of file
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