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
5576f59a
Commit
5576f59a
authored
Mar 23, 2026
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化了浏览器启动与刷新的日志与失败重试策略(含连续失败计数)、下调了部分非致命错误日志级别,并调整了 ship0301 设备转向参数
parent
49f1f6e0
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
29 deletions
+61
-29
device_id_change.c
app/device_change/device_id_change.c
+1
-1
pthread_open.c
app/main/pthread_open.c
+1
-1
main
build/main
+0
-0
ship0301_control.c
drivers/devicecontrol/ship0301_control.c
+1
-4
browser_open.c
modules/browser/browser_open.c
+54
-19
tailscale_deploy.c
modules/tailscale_deploy/tailscale_deploy.c
+3
-3
zlog.conf
zlog.conf
+1
-1
No files found.
app/device_change/device_id_change.c
View file @
5576f59a
...
@@ -143,7 +143,7 @@ time_t extract_timestamp(const char *filename) {
...
@@ -143,7 +143,7 @@ time_t extract_timestamp(const char *filename) {
char
*
find_latest_file
(
const
char
*
dir_path
)
{
char
*
find_latest_file
(
const
char
*
dir_path
)
{
DIR
*
dir
=
opendir
(
dir_path
);
DIR
*
dir
=
opendir
(
dir_path
);
if
(
!
dir
)
{
if
(
!
dir
)
{
my_zlog_
error
(
"无法打开目录: %s"
,
dir_path
);
my_zlog_
warn
(
"无法打开目录: %s"
,
dir_path
);
return
NULL
;
return
NULL
;
}
}
...
...
app/main/pthread_open.c
View file @
5576f59a
...
@@ -177,7 +177,7 @@ void *thread_open_browser(void *arg)
...
@@ -177,7 +177,7 @@ void *thread_open_browser(void *arg)
int
result
=
system
(
"pkill chromium"
);
int
result
=
system
(
"pkill chromium"
);
if
(
result
!=
0
)
if
(
result
!=
0
)
{
{
my_zlog_
error
(
"system error,chrmium is close"
);
my_zlog_
warn
(
"system error,chrmium is close"
);
}
}
delay_s
(
5
);
delay_s
(
5
);
while
(
1
)
while
(
1
)
...
...
build/main
View file @
5576f59a
No preview for this file type
drivers/devicecontrol/ship0301_control.c
View file @
5576f59a
...
@@ -135,7 +135,7 @@ void ship0301_change(int *buf) {
...
@@ -135,7 +135,7 @@ void ship0301_change(int *buf) {
ship0301_mode_lift_back
(
ship0301_front_val
);
ship0301_mode_lift_back
(
ship0301_front_val
);
ship0301_mode_right_back
(
ship0301_front_val
);
ship0301_mode_right_back
(
ship0301_front_val
);
}
else
if
(
ship0301_front_t
==
0
&&
ship0301_steering_t
==
1
){
}
else
if
(
ship0301_front_t
==
0
&&
ship0301_steering_t
==
1
){
ship0301_mode_right_flont
(
ship0301_steering_val
+
ship0301_count
);
ship0301_mode_right_flont
(
ship0301_steering_val
+
ship0301_count
+
10
);
ship0301_mode_lift_flont
(
0
);
ship0301_mode_lift_flont
(
0
);
}
else
if
(
ship0301_front_t
==
0
&&
ship0301_steering_t
==
2
){
}
else
if
(
ship0301_front_t
==
0
&&
ship0301_steering_t
==
2
){
ship0301_mode_right_flont
(
0
);
ship0301_mode_right_flont
(
0
);
...
@@ -156,6 +156,4 @@ void ship0301_change(int *buf) {
...
@@ -156,6 +156,4 @@ void ship0301_change(int *buf) {
}
}
\ No newline at end of file
modules/browser/browser_open.c
View file @
5576f59a
...
@@ -4,17 +4,37 @@
...
@@ -4,17 +4,37 @@
#include "http_config_mqtt.h"
#include "http_config_mqtt.h"
static
char
s_webcam
[
2048
];
//存放启动火狐网站命令
static
char
s_webcam
[
2048
];
//存放启动火狐网站命令
static
int
s_open_cam_enter_count
=
0
;
// 记录 opencamsh 进入次数
static
int
s_open_cam_fail_streak
=
0
;
// 连续启动失败次数
static
int
s_refresh_cam_enter_count
=
0
;
// 记录 refresh_cam 进入次数
static
int
s_refresh_cam_fail_count
=
0
;
// 刷新失败累计次数
int
opencamsh
()
{
int
opencamsh
()
{
char
urls
[
512
];
char
urls
[
512
];
int
cmd_ret
=
0
;
s_open_cam_enter_count
++
;
my_zlog_info
(
"opencamsh enter count:%d"
,
s_open_cam_enter_count
);
s
printf
(
urls
,
"%s%s"
,
g_mqtt_cam_config_t
->
videourl
,
mqtt_topic_pure_number
());
s
nprintf
(
urls
,
sizeof
(
urls
),
"%s%s"
,
g_mqtt_cam_config_t
->
videourl
,
mqtt_topic_pure_number
());
//setenv("DISPLAY", ":0", 1);//设置环境变量https://jywy.yd-ss.com?dev=controcar0004 --new-window sudo
//setenv("DISPLAY", ":0", 1);//设置环境变量https://jywy.yd-ss.com?dev=controcar0004 --new-window sudo
sprintf
(
s_webcam
,
"su - orangepi -c
\"
chromium-browser --use-fake-ui-for-media-stream %s
\"
"
,
urls
);
snprintf
(
s_webcam
,
sizeof
(
s_webcam
),
"su - orangepi -c
\"
chromium-browser --use-fake-ui-for-media-stream %s
\"
"
,
urls
);
if
(
system
(
s_webcam
)
!=
0
){
cmd_ret
=
system
(
s_webcam
);
my_zlog_error
(
"start fail"
);
if
(
cmd_ret
!=
0
)
{
s_open_cam_fail_streak
++
;
if
(
s_open_cam_fail_streak
>=
10
&&
(
s_open_cam_fail_streak
%
10
)
==
0
)
{
my_zlog_error
(
"chromium start fail, ret:%d, continuous fail:%d, enter count:%d"
,
cmd_ret
,
s_open_cam_fail_streak
,
s_open_cam_enter_count
);
}
else
{
my_zlog_warn
(
"chromium start fail, ret:%d, continuous fail:%d, enter count:%d"
,
cmd_ret
,
s_open_cam_fail_streak
,
s_open_cam_enter_count
);
}
}
else
{
if
(
s_open_cam_fail_streak
>
0
)
{
my_zlog_info
(
"chromium start recovered, previous continuous fail:%d"
,
s_open_cam_fail_streak
);
}
s_open_cam_fail_streak
=
0
;
}
}
my_zlog_debug
(
"%s"
,
s_webcam
);
my_zlog_debug
(
"%s"
,
s_webcam
);
my_zlog_debug
(
"open cam"
);
my_zlog_debug
(
"open cam"
);
...
@@ -23,7 +43,13 @@ int opencamsh() {
...
@@ -23,7 +43,13 @@ int opencamsh() {
void
refresh_cam
()
{
//刷新页面
void
refresh_cam
()
{
//刷新页面
int
refreshed_windows
=
0
;
int
failed_windows
=
0
;
s_refresh_cam_enter_count
++
;
my_zlog_info
(
"refresh_cam enter count:%d"
,
s_refresh_cam_enter_count
);
setenv
(
"DISPLAY"
,
":0"
,
1
);
// 确保 xdotool 在图形会话中执行
setenv
(
"XAUTHORITY"
,
"/home/orangepi/.Xauthority"
,
1
);
//加入授权
setenv
(
"XAUTHORITY"
,
"/home/orangepi/.Xauthority"
,
1
);
//加入授权
const
char
*
search_command
=
"xdotool search --class
\"
chromium-browser
\"
"
;
//获取窗口id
const
char
*
search_command
=
"xdotool search --class
\"
chromium-browser
\"
"
;
//获取窗口id
...
@@ -31,7 +57,8 @@ void refresh_cam() {//刷新页面
...
@@ -31,7 +57,8 @@ void refresh_cam() {//刷新页面
FILE
*
fp
=
popen
(
search_command
,
"r"
);
FILE
*
fp
=
popen
(
search_command
,
"r"
);
if
(
!
fp
)
{
if
(
!
fp
)
{
perror
(
"Failed to execute search command"
);
s_refresh_cam_fail_count
++
;
my_zlog_error
(
"refresh_cam popen fail, total fail:%d"
,
s_refresh_cam_fail_count
);
return
;
return
;
}
}
...
@@ -44,24 +71,32 @@ void refresh_cam() {//刷新页面
...
@@ -44,24 +71,32 @@ void refresh_cam() {//刷新页面
snprintf
(
activate_command
,
sizeof
(
activate_command
),
"xdotool windowactivate --sync %s key Ctrl+r"
,
window_id
);
snprintf
(
activate_command
,
sizeof
(
activate_command
),
"xdotool windowactivate --sync %s key Ctrl+r"
,
window_id
);
pid_t
pid
=
fork
();
if
(
system
(
activate_command
)
==
0
)
{
refreshed_windows
++
;
if
(
pid
==
0
)
{
// 子进程执行命令
execl
(
"/bin/sh"
,
"sh"
,
"-c"
,
activate_command
,
(
char
*
)
NULL
);
perror
(
"Failed to execute command"
);
exit
(
EXIT_FAILURE
);
}
else
if
(
pid
>
0
)
{
// 父进程不等待子进程结束,继续执行
printf
(
"Executing in child process: %s
\n
"
,
activate_command
);
}
else
{
}
else
{
perror
(
"Failed to fork"
);
failed_windows
++
;
my_zlog_warn
(
"refresh_cam command fail, window id:%s"
,
window_id
);
}
}
}
}
pclose
(
fp
);
pclose
(
fp
);
//printf("recam\n");
my_zlog_debug
(
"刷新成功"
);
if
(
refreshed_windows
==
0
)
{
s_refresh_cam_fail_count
++
;
my_zlog_warn
(
"refresh_cam no chromium window, total fail:%d, enter count:%d"
,
s_refresh_cam_fail_count
,
s_refresh_cam_enter_count
);
return
;
}
if
(
failed_windows
>
0
)
{
s_refresh_cam_fail_count
++
;
my_zlog_warn
(
"refresh_cam partial fail, success:%d fail:%d total fail:%d"
,
refreshed_windows
,
failed_windows
,
s_refresh_cam_fail_count
);
return
;
}
my_zlog_info
(
"refresh_cam success, windows:%d, enter count:%d"
,
refreshed_windows
,
s_refresh_cam_enter_count
);
}
}
// 检查Chromium进程是否已运行
// 检查Chromium进程是否已运行
...
...
modules/tailscale_deploy/tailscale_deploy.c
View file @
5576f59a
...
@@ -36,7 +36,7 @@ int tailscale_control(cJSON *body) {
...
@@ -36,7 +36,7 @@ int tailscale_control(cJSON *body) {
if
(
WEXITSTATUS
(
ret
)
==
0
)
{
if
(
WEXITSTATUS
(
ret
)
==
0
)
{
my_zlog_info
(
"tailscale_control: Tailscale stopped successfully"
);
my_zlog_info
(
"tailscale_control: Tailscale stopped successfully"
);
}
else
{
}
else
{
my_zlog_
error
(
"tailscale_control: Failed to stop Tailscale, ret=%d"
,
WEXITSTATUS
(
ret
));
my_zlog_
warn
(
"tailscale_control: Failed to stop Tailscale, ret=%d"
,
WEXITSTATUS
(
ret
));
return
-
3
;
return
-
3
;
}
}
}
else
{
}
else
{
...
@@ -51,7 +51,7 @@ int tailscale_control(cJSON *body) {
...
@@ -51,7 +51,7 @@ int tailscale_control(cJSON *body) {
// 安装 tailscale
// 安装 tailscale
int
install_ret
=
system
(
"curl -fsSL https://tailscale.com/install.sh | sh"
);
int
install_ret
=
system
(
"curl -fsSL https://tailscale.com/install.sh | sh"
);
if
(
install_ret
!=
0
)
{
if
(
install_ret
!=
0
)
{
my_zlog_
error
(
"tailscale_control: Failed to install Tailscale, ret=%d"
,
install_ret
);
my_zlog_
warn
(
"tailscale_control: Failed to install Tailscale, ret=%d"
,
install_ret
);
return
-
4
;
return
-
4
;
}
}
// 用户要求不开机自启,因此先 disable
// 用户要求不开机自启,因此先 disable
...
@@ -80,7 +80,7 @@ int tailscale_control(cJSON *body) {
...
@@ -80,7 +80,7 @@ int tailscale_control(cJSON *body) {
if
(
WEXITSTATUS
(
start_ret
)
==
0
)
{
if
(
WEXITSTATUS
(
start_ret
)
==
0
)
{
my_zlog_info
(
"tailscale_control: Tailscale started successfully"
);
my_zlog_info
(
"tailscale_control: Tailscale started successfully"
);
}
else
{
}
else
{
my_zlog_
error
(
"tailscale_control: Failed to start Tailscale, ret=%d"
,
WEXITSTATUS
(
start_ret
));
my_zlog_
warn
(
"tailscale_control: Failed to start Tailscale, ret=%d"
,
WEXITSTATUS
(
start_ret
));
return
-
5
;
return
-
5
;
}
}
}
else
{
}
else
{
...
...
zlog.conf
View file @
5576f59a
...
@@ -9,4 +9,4 @@ file perms = 600
...
@@ -9,4 +9,4 @@ file perms = 600
millisecond
=
"%d(%Y-%m-%d %H:%M:%S).%ms [%V] %m%n"
millisecond
=
"%d(%Y-%m-%d %H:%M:%S).%ms [%V] %m%n"
[
rules
]
[
rules
]
my_log
.*
"/home/orangepi/car/master/log/log_2026-03-
19
.log"
;
millisecond
my_log
.*
"/home/orangepi/car/master/log/log_2026-03-
23
.log"
;
millisecond
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