Commit 9dd2aa26 authored by 957dd's avatar 957dd

mowtm32

parent f303639d
controlcars0001
\ No newline at end of file
......@@ -17,7 +17,7 @@ def get_local_ip():
def write_to_file(data):
try:
# 打开文件,模式为写入模式(会清空已有内容)
with open("/home/kickpi/car/master/Deviceld.txt", "w", encoding="utf-8") as file:
with open("/home/orangepi/car/master/Deviceld.txt", "w", encoding="utf-8") as file:
file.write(data)
print("数据已成功写入 Deviceld.txt")
except Exception as e:
......@@ -26,8 +26,8 @@ def write_to_file(data):
def read_from_file():
try:
if os.path.exists("/home/kickpi/car/master/Deviceld.txt"):
with open("/home/kickpi/car/master/Deviceld.txt", "r", encoding="utf-8") as file:
if os.path.exists("/home/orangepi/car/master/Deviceld.txt"):
with open("/home/orangepi/car/master/Deviceld.txt", "r", encoding="utf-8") as file:
return file.read()
return "文件内容为空。"
except Exception as e:
......
......@@ -2,7 +2,7 @@
#define __MAIN_H__
#define filename "/home/kickpi/car/master/Deviceld.txt"
#define filename "/home/orangepi/car/master/Deviceld.txt"
pthread_t thread[5];
......@@ -45,6 +45,8 @@ void *Mqttbeat(void *arg),void *serial_usart2(void *arg),void *opensh(void *arg)
perror("Failed to create thread 6");
return 6;
}
return 0;
}
// 等待线程结束
......
......@@ -23,7 +23,7 @@ extern int gmessage_type;
extern unsigned char gtypeTemp;
int mqtt_init();
int mqtt_create(struct mosquitto *mosq);
void mqtt_create(struct mosquitto *mosq);
void on_connect(struct mosquitto *mosq, void *obj, int rc);
void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message) ;
void mqtt_MAC_wirte();
......
......@@ -3,8 +3,8 @@
#define SERIAL_PORT1 "/dev/ttyS3" // 根据实际设备修改
#define SERIAL_PORT2 "/dev/ttyS0"
#define SERIAL_PORT1 "/dev/ttyS1" // 根据实际设备修改
#define SERIAL_PORT2 "/dev/ttyS2"
#define BUFFER_SIZE 256
int serial_Init();
void serial_Receive_1();
......
No preview for this file type
# 编译器
CC = gcc
# 编译选项
CFLAGS = -Wall -g -Ilib
# 链接库
LDFLAGS = -lwiringPi -lmosquitto -lcjson
# 目标可执行文件
TARGET = main
# 源文件目录
SRC_DIR = usr src
# 头文件目录
INC_DIR = lib
# 查找所有 .c 文件
SRCS = $(foreach dir,$(SRC_DIR),$(wildcard $(dir)/*.c))
# 目标文件
OBJS = $(SRCS:.c=.o)
# 默认目标
all: $(TARGET)
# 链接目标文件生成可执行文件
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LDFLAGS)
# 编译每个 .c 文件为 .o 文件
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
# 清理生成的文件
clean:
rm -f $(OBJS) $(TARGET)
File added
File added
File added
......@@ -282,7 +282,7 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag
}
int mqtt_create(struct mosquitto *mosq) //创建mqtt客服端
void mqtt_create(struct mosquitto *mosq) //创建mqtt客服端
{
mosquitto_reconnect_delay_set(mosq, 2, 10, true);
......@@ -301,6 +301,8 @@ int mqtt_create(struct mosquitto *mosq) //创建mqtt客服端
mosquitto_destroy(mosq);
//return EXIT_FAILURE;
}
}
......
File added
......@@ -26,6 +26,8 @@ int opencamsh()
system(gwebcam);
printf("%s\n",gwebcam);
printf("close cam\n");
return 0;
}
......@@ -79,4 +81,6 @@ int reconnect_4g()
// 关闭文件
fclose(file);
return 0;
}
File added
......@@ -156,5 +156,5 @@ int serial_Init()
return -1;
printf("Serial 2 communication started...\n");
}
return 0;
}
File added
......@@ -114,7 +114,6 @@ void *Mqtt_onnect(void *arg)
char *device_inspect()
{
FILE *file;
int size=0;
while (1) {
file = fopen(filename, "r"); // 以只读模式打开文件
......
File added
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