Commit c063a013 authored by 957dd's avatar 957dd

add firefox refresh

parent 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
#!/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
This diff is collapsed.
No preview for this file type
...@@ -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,200); 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);
......
#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;
......
...@@ -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 "controlcar0001" #define TOPIC "controcar0004"
#define USERNAME "admin" // 替换为你的用户名 #define USERNAME "admin" // 替换为你的用户名
#define PASSWORD "admin" // 替换为你的密码 #define PASSWORD "admin" // 替换为你的密码
......
...@@ -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");
}
...@@ -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
#!/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
...@@ -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)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment