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
c063a013
Commit
c063a013
authored
Dec 20, 2024
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add firefox refresh
parent
07e6627a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
71 additions
and
28 deletions
+71
-28
cam.sh
cam.sh
+0
-10
camopen.sh
camopen.sh
+12
-0
log.txt
log/log.txt
+0
-0
main
main
+0
-0
main.c
main.c
+15
-11
mqtt.c
mqtt.c
+10
-1
mqtt.h
mqtt.h
+3
-3
opensh.c
opensh.c
+8
-1
opensh.h
opensh.h
+5
-1
recam.sh
recam.sh
+17
-0
serial.c
serial.c
+1
-1
No files found.
cam.sh
deleted
100755 → 0
View file @
07e6627a
#!/bin/bash
pkill firefox
# 设置 DISPLAY 环境变量(确保 Firefox 能运行图形界面)--new-window
export
DISPLAY
=
:0
sudo
firefox
"https://8.129.3.163/index"
--ignore-certificate-errors
\ No newline at end of file
camopen.sh
0 → 100755
View file @
c063a013
#!/bin/bash
#sudo wmctrl -c firefox
#sleep 2 pkill firefox
# 设置 DISPLAY 环境变量(确保 Firefox 能运行图形界面)--new-window--ignore-certificate-errors
export
DISPLAY
=
:0
firefox
"https://8.129.3.163/index"
&
\ No newline at end of file
log/log.txt
View file @
c063a013
This diff is collapsed.
Click to expand it.
main
View file @
c063a013
No preview for this file type
main.c
View file @
c063a013
...
@@ -5,12 +5,7 @@
...
@@ -5,12 +5,7 @@
#include "delay.h"
#include "delay.h"
#include "opensh.h"
#include "opensh.h"
void
*
opensh
(
void
*
arg
)
{
sleep
(
10
);
opencamsh
();
return
NULL
;
}
void
*
serial_usart1
(
void
*
arg
)
void
*
serial_usart1
(
void
*
arg
)
{
{
...
@@ -24,14 +19,16 @@ void *serial_usart1(void *arg)
...
@@ -24,14 +19,16 @@ void *serial_usart1(void *arg)
void
*
AppExit
(
void
*
arg
)
void
*
AppExit
(
void
*
arg
)
{
{
while
(
1
)
while
(
1
)
{
{
unsigned
char
bufpwm1
[
3
]
=
{
gtypeTemp
,
1
,
0
};
unsigned
char
bufpwm1
[
3
]
=
{
gtypeTemp
,
1
,
0
};
unsigned
char
bufpwm2
[
3
]
=
{
gtypeTemp
,
2
,
0
};
unsigned
char
bufpwm2
[
3
]
=
{
gtypeTemp
,
2
,
0
};
unsigned
char
bufpwm3
[
3
]
=
{
gtypeTemp
,
3
,
0
};
unsigned
char
bufpwm3
[
3
]
=
{
gtypeTemp
,
3
,
0
};
unsigned
char
bufpwm4
[
3
]
=
{
gtypeTemp
,
4
,
0
};
unsigned
char
bufpwm4
[
3
]
=
{
gtypeTemp
,
4
,
0
};
\
if
(
gtypeTemp
==
3
)
{
gPwmCount
=
0
;
}
Delay_Ms
(
0
,
100
);
Delay_Ms
(
0
,
100
);
gPwmCount
++
;
gPwmCount
++
;
//printf( "%d\n",gtypeTemp);
//printf( "%d\n",gtypeTemp);
...
@@ -57,13 +54,21 @@ void *Mqttbeat(void *arg)
...
@@ -57,13 +54,21 @@ void *Mqttbeat(void *arg)
while
(
1
)
while
(
1
)
{
{
mqtt_wirte
();
mqtt_wirte
();
Delay_Ms
(
3
,
20
0
);
Delay_Ms
(
3
,
0
);
}
}
return
NULL
;
return
NULL
;
}
}
void
*
opensh
(
void
*
arg
)
{
Delay_Ms
(
10
,
0
);
printf
(
"open cam
\n
"
);
opencamsh
();
return
NULL
;
}
void
*
serial_usart2
(
void
*
arg
)
void
*
serial_usart2
(
void
*
arg
)
{
{
...
@@ -88,7 +93,6 @@ int main(int argc, char *argv[]) {
...
@@ -88,7 +93,6 @@ int main(int argc, char *argv[]) {
ipaddr
();
//获取ip
ipaddr
();
//获取ip
mqtt_wirte
();
//mqtt心跳首次发送
mqtt_wirte
();
//mqtt心跳首次发送
//opencamsh();
thread_start
(
serial_usart1
,
AppExit
,
Mqttbeat
,
serial_usart2
,
opensh
);
thread_start
(
serial_usart1
,
AppExit
,
Mqttbeat
,
serial_usart2
,
opensh
);
mqtt_cycle
(
mosq
);
mqtt_cycle
(
mosq
);
...
...
mqtt.c
View file @
c063a013
#include "mqtt.h"
#include "mqtt.h"
#include "gps.h"
#include "gps.h"
#include "opensh.h"
time_t
gStart
;
time_t
gStart
;
...
@@ -35,7 +36,7 @@ int mqtt_init()
...
@@ -35,7 +36,7 @@ int mqtt_init()
{
{
// 初始化 mosquitto 库
// 初始化 mosquitto 库
mosquitto_lib_init
();
mosquitto_lib_init
();
mosq
=
mosquitto_new
(
CLIENT_ID
,
true
,
NULL
);
mosq
=
mosquitto_new
(
NULL
,
true
,
NULL
);
if
(
!
mosq
)
{
if
(
!
mosq
)
{
fprintf
(
stderr
,
"Failed to create Mosquitto client
\n
"
);
fprintf
(
stderr
,
"Failed to create Mosquitto client
\n
"
);
return
-
1
;
return
-
1
;
...
@@ -131,6 +132,7 @@ void message_0()//message_type为0时候要改变的值
...
@@ -131,6 +132,7 @@ void message_0()//message_type为0时候要改变的值
}
}
void
message_3
(
cJSON
*
body
,
cJSON
*
pwm_ctrl
)
//message_type为3,控制pwm
void
message_3
(
cJSON
*
body
,
cJSON
*
pwm_ctrl
)
//message_type为3,控制pwm
{
{
//pwm控制
//pwm控制
...
@@ -147,6 +149,10 @@ void message_3(cJSON *body,cJSON *pwm_ctrl)//message_type为3,控制pwm
...
@@ -147,6 +149,10 @@ void message_3(cJSON *body,cJSON *pwm_ctrl)//message_type为3,控制pwm
gmodeTemp
=
mode
->
valueint
;
gmodeTemp
=
mode
->
valueint
;
gtypeTemp
=
type
->
valueint
;
gtypeTemp
=
type
->
valueint
;
gvalTemp
=
val
->
valueint
*
3
/
4
;
gvalTemp
=
val
->
valueint
*
3
/
4
;
if
(
gtypeTemp
==
3
)
{
gvalTemp
=
val
->
valueint
;
}
gvalt
[
0
]
=
gtypeTemp
;
gvalt
[
0
]
=
gtypeTemp
;
gvalt
[
1
]
=
gmodeTemp
;
gvalt
[
1
]
=
gmodeTemp
;
gvalt
[
2
]
=
gvalTemp
;
gvalt
[
2
]
=
gvalTemp
;
...
@@ -243,6 +249,9 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag
...
@@ -243,6 +249,9 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag
case
0
:
case
0
:
message_0
();
message_0
();
break
;
break
;
case
2
:
refresh_cam
();
break
;
case
3
:
case
3
:
message_3
(
body
,
pwm_ctrl
);
message_3
(
body
,
pwm_ctrl
);
break
;
break
;
...
...
mqtt.h
View file @
c063a013
...
@@ -8,12 +8,12 @@
...
@@ -8,12 +8,12 @@
#include "ip.h"
#include "ip.h"
#include "serial.h"
#include "serial.h"
#define CLIENT_ID "carorship123"
#define BROKER_ADDRESS "119.45.167.177"
#define BROKER_ADDRESS "119.45.167.177"
#define BROKER_PORT 1883
#define BROKER_PORT 1883
#define CLIENT_ID "feichirensheng/carorship"
#define TOPIC "contro
lcar0001
"
#define TOPIC "contro
car0004
"
#define USERNAME "admin" // 替换为你的用户名
#define USERNAME "admin" // 替换为你的用户名
#define PASSWORD "admin" // 替换为你的密码
#define PASSWORD "admin" // 替换为你的密码
...
...
opensh.c
View file @
c063a013
...
@@ -9,6 +9,13 @@ int opencamsh()
...
@@ -9,6 +9,13 @@ int opencamsh()
{
{
return
-
1
;
return
-
1
;
}
}
printf
(
"
open
cam
\n
"
);
printf
(
"
close
cam
\n
"
);
}
}
void
refresh_cam
()
{
system
(
SHELLFILECLOSE
);
printf
(
"recam
\n
"
);
}
opensh.h
View file @
c063a013
...
@@ -2,7 +2,10 @@
...
@@ -2,7 +2,10 @@
#define __opensh_H__
#define __opensh_H__
#define SHELLFILE "/home/kickpi/car/master/cam.sh"
#define SHELLFILE "/home/kickpi/car/master/camopen.sh"
#define SHELLFILECLOSE "/home/kickpi/car/master/recam.sh"
int
opencamsh
();
int
opencamsh
();
void
refresh_cam
();
#endif
#endif
\ No newline at end of file
recam.sh
0 → 100755
View file @
c063a013
#!/bin/bash
irefox_windows
=
$(
xdotool search
--name
"Call 1V1 — Mozilla Firefox"
)
# 判断是否找到 Firefox 窗口
#if [ -z "$firefox_windows" ]; then
#echo "没有找到任何 Firefox 窗口。"
#exit 1
#fi
# 刷新所有找到的 Firefox 窗口 #echo "刷新窗口 ID: $window"
for
window
in
$irefox_windows
;
do
xdotool windowactivate
$window
key Ctrl+r
done
\ No newline at end of file
serial.c
View file @
c063a013
...
@@ -75,7 +75,7 @@ void serial_Receive_2()
...
@@ -75,7 +75,7 @@ void serial_Receive_2()
void
serial_Receive_1
()
void
serial_Receive_1
()
{
{
unsigned
char
buffer
[
3
];
unsigned
char
buffer
[
256
];
while
(
1
)
while
(
1
)
{
{
...
...
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