Commit 438d9a5e authored by 957dd's avatar 957dd

3

parent b0ceaf43
...@@ -296,6 +296,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o ...@@ -296,6 +296,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o
/usr/include/aarch64-linux-gnu/bits/local_lim.h /usr/include/aarch64-linux-gnu/bits/local_lim.h
/usr/include/linux/limits.h /usr/include/linux/limits.h
/usr/include/aarch64-linux-gnu/bits/posix2_lim.h /usr/include/aarch64-linux-gnu/bits/posix2_lim.h
/usr/include/aarch64-linux-gnu/bits/xopen_lim.h
/usr/include/aarch64-linux-gnu/bits/uio_lim.h
/usr/include/aarch64-linux-gnu/sys/time.h /usr/include/aarch64-linux-gnu/sys/time.h
/usr/include/aarch64-linux-gnu/curl/easy.h /usr/include/aarch64-linux-gnu/curl/easy.h
/usr/include/aarch64-linux-gnu/curl/multi.h /usr/include/aarch64-linux-gnu/curl/multi.h
...@@ -311,7 +313,6 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o ...@@ -311,7 +313,6 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o
/home/orangepi/car/master/include/log.h /home/orangepi/car/master/include/log.h
/home/orangepi/car/master/include/delay.h /home/orangepi/car/master/include/delay.h
/home/orangepi/car/master/device_judg/device/device_change.h /home/orangepi/car/master/device_judg/device/device_change.h
/home/orangepi/car/master/include/download.h
CMakeFiles/main.dir/device_judg/device/pao.c.o CMakeFiles/main.dir/device_judg/device/pao.c.o
/home/orangepi/car/master/device_judg/device/pao.c /home/orangepi/car/master/device_judg/device/pao.c
...@@ -2040,6 +2041,7 @@ CMakeFiles/main.dir/src/mqtt.c.o ...@@ -2040,6 +2041,7 @@ CMakeFiles/main.dir/src/mqtt.c.o
/usr/include/cjson/cJSON.h /usr/include/cjson/cJSON.h
/home/orangepi/car/master/system/sensor/warm.h /home/orangepi/car/master/system/sensor/warm.h
/home/orangepi/car/master/include/fileopen.h /home/orangepi/car/master/include/fileopen.h
/home/orangepi/car/master/device_judg/device/device_change.h
/home/orangepi/car/master/device_judg/judg/judg.h /home/orangepi/car/master/device_judg/judg/judg.h
CMakeFiles/main.dir/src/opensh.c.o CMakeFiles/main.dir/src/opensh.c.o
......
...@@ -294,6 +294,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: ../device_judg/device/ ...@@ -294,6 +294,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: ../device_judg/device/
/usr/include/aarch64-linux-gnu/bits/local_lim.h \ /usr/include/aarch64-linux-gnu/bits/local_lim.h \
/usr/include/linux/limits.h \ /usr/include/linux/limits.h \
/usr/include/aarch64-linux-gnu/bits/posix2_lim.h \ /usr/include/aarch64-linux-gnu/bits/posix2_lim.h \
/usr/include/aarch64-linux-gnu/bits/xopen_lim.h \
/usr/include/aarch64-linux-gnu/bits/uio_lim.h \
/usr/include/aarch64-linux-gnu/sys/time.h \ /usr/include/aarch64-linux-gnu/sys/time.h \
/usr/include/aarch64-linux-gnu/curl/easy.h \ /usr/include/aarch64-linux-gnu/curl/easy.h \
/usr/include/aarch64-linux-gnu/curl/multi.h \ /usr/include/aarch64-linux-gnu/curl/multi.h \
...@@ -308,8 +310,7 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: ../device_judg/device/ ...@@ -308,8 +310,7 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: ../device_judg/device/
../system/gpio/gpio_common.h \ ../system/gpio/gpio_common.h \
../include/log.h \ ../include/log.h \
../include/delay.h \ ../include/delay.h \
../device_judg/device/device_change.h \ ../device_judg/device/device_change.h
../include/download.h
CMakeFiles/main.dir/device_judg/device/pao.c.o: ../device_judg/device/pao.c \ CMakeFiles/main.dir/device_judg/device/pao.c.o: ../device_judg/device/pao.c \
/usr/include/stdc-predef.h \ /usr/include/stdc-predef.h \
...@@ -2027,6 +2028,7 @@ CMakeFiles/main.dir/src/mqtt.c.o: ../src/mqtt.c \ ...@@ -2027,6 +2028,7 @@ CMakeFiles/main.dir/src/mqtt.c.o: ../src/mqtt.c \
/usr/include/cjson/cJSON.h \ /usr/include/cjson/cJSON.h \
../system/sensor/warm.h \ ../system/sensor/warm.h \
../include/fileopen.h \ ../include/fileopen.h \
../device_judg/device/device_change.h \
../device_judg/judg/judg.h ../device_judg/judg/judg.h
CMakeFiles/main.dir/src/opensh.c.o: ../src/opensh.c \ CMakeFiles/main.dir/src/opensh.c.o: ../src/opensh.c \
...@@ -6632,10 +6634,6 @@ CMakeFiles/main.dir/zlog/src/zlog.c.o: ../zlog/src/zlog.c \ ...@@ -6632,10 +6634,6 @@ CMakeFiles/main.dir/zlog/src/zlog.c.o: ../zlog/src/zlog.c \
../device_judg/device/device_change.h: ../device_judg/device/device_change.h:
../include/download.h:
../system/sensor/heat.h:
../device_judg/device/pao.c: ../device_judg/device/pao.c:
../include/ip.h: ../include/ip.h:
...@@ -6652,6 +6650,10 @@ CMakeFiles/main.dir/zlog/src/zlog.c.o: ../zlog/src/zlog.c \ ...@@ -6652,6 +6650,10 @@ CMakeFiles/main.dir/zlog/src/zlog.c.o: ../zlog/src/zlog.c \
../src/download.c: ../src/download.c:
../include/download.h:
../system/sensor/heat.h:
/usr/include/aarch64-linux-gnu/bits/getopt_posix.h: /usr/include/aarch64-linux-gnu/bits/getopt_posix.h:
../src/fileopen.c: ../src/fileopen.c:
......
...@@ -116,6 +116,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: \ ...@@ -116,6 +116,8 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: \
/usr/include/aarch64-linux-gnu/bits/local_lim.h \ /usr/include/aarch64-linux-gnu/bits/local_lim.h \
/usr/include/linux/limits.h \ /usr/include/linux/limits.h \
/usr/include/aarch64-linux-gnu/bits/posix2_lim.h \ /usr/include/aarch64-linux-gnu/bits/posix2_lim.h \
/usr/include/aarch64-linux-gnu/bits/xopen_lim.h \
/usr/include/aarch64-linux-gnu/bits/uio_lim.h \
/usr/include/aarch64-linux-gnu/sys/time.h \ /usr/include/aarch64-linux-gnu/sys/time.h \
/usr/include/aarch64-linux-gnu/curl/easy.h \ /usr/include/aarch64-linux-gnu/curl/easy.h \
/usr/include/aarch64-linux-gnu/curl/multi.h \ /usr/include/aarch64-linux-gnu/curl/multi.h \
...@@ -129,5 +131,4 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: \ ...@@ -129,5 +131,4 @@ CMakeFiles/main.dir/device_judg/device/device_change.c.o: \
/home/orangepi/car/master/system/gpio/gpio_common.h \ /home/orangepi/car/master/system/gpio/gpio_common.h \
/home/orangepi/car/master/include/log.h \ /home/orangepi/car/master/include/log.h \
/home/orangepi/car/master/include/delay.h \ /home/orangepi/car/master/include/delay.h \
/home/orangepi/car/master/device_judg/device/device_change.h \ /home/orangepi/car/master/device_judg/device/device_change.h
/home/orangepi/car/master/include/download.h
...@@ -141,4 +141,5 @@ CMakeFiles/main.dir/src/mqtt.c.o: /home/orangepi/car/master/src/mqtt.c \ ...@@ -141,4 +141,5 @@ CMakeFiles/main.dir/src/mqtt.c.o: /home/orangepi/car/master/src/mqtt.c \
/usr/include/cjson/cJSON.h \ /usr/include/cjson/cJSON.h \
/home/orangepi/car/master/system/sensor/warm.h \ /home/orangepi/car/master/system/sensor/warm.h \
/home/orangepi/car/master/include/fileopen.h \ /home/orangepi/car/master/include/fileopen.h \
/home/orangepi/car/master/device_judg/device/device_change.h \
/home/orangepi/car/master/device_judg/judg/judg.h /home/orangepi/car/master/device_judg/judg/judg.h
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
#define PROJECT_VERSION_MINOR 1 #define PROJECT_VERSION_MINOR 1
#define PROJECT_VERSION_PATCH 0 #define PROJECT_VERSION_PATCH 0
#define GIT_HASH "" #define GIT_HASH ""
#define BUILD_TIMESTAMP "2025-05-08T12:02:23" #define BUILD_TIMESTAMP "2025-05-10T08:31:49"
#define BUILD_USER "orangepi" #define BUILD_USER "orangepi"
No preview for this file type
This diff is collapsed.
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#define DEVICE_NAME_DIR "/home/orangepi/car/master/deviceback" #define DEVICE_NAME_DIR "/home/orangepi/car/master/deviceback"
int device_changename_back(); #define DEVICE_NAME_FILE "/home/orangepi/car/master/Deviceld.txt"
int device_changename_back(const char *device_date, const char *device_id);
const char *find_latest_file(const char *dir_path);
#endif #endif
\ No newline at end of file
00010200000000
\ No newline at end of file
...@@ -3,6 +3,4 @@ ...@@ -3,6 +3,4 @@
int download_file(const char *url,const char *target_dir ,const char *filename) ;//下载文件 int download_file(const char *url,const char *target_dir ,const char *filename) ;//下载文件
int file_exists(const char *path);//检查文件是否存在
int remove_file(const char *path); // 删除文件
#endif #endif
\ No newline at end of file
...@@ -27,44 +27,39 @@ static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, voi ...@@ -27,44 +27,39 @@ static size_t WriteMemoryCallback(void *contents, size_t size, size_t nmemb, voi
} }
// 检查文件是否存在 // 检查并创建日志目录
int file_exists(const char *path) { int create_directory_if_not_exists(const char *path) {
return access(path, F_OK) == 0; char temp[1024];
} size_t len = strlen(path);
// 删除文件 if (len >= sizeof(temp)) {
int remove_file(const char *path) { my_zlog_error("路径过长: %s", path);
if (remove(path) == 0) { return -1;
return 1;
} else {
my_zlog_warn("删除文件失败");
return 0;
} }
}
// 检查并创建日志目录 // 拷贝路径并保证以 '/' 结尾
static int create_directory_if_not_exists(const char *path) { strncpy(temp, path, sizeof(temp));
char dir_path[256] = {0}; if (temp[len - 1] != '/') {
const char *p = path; temp[len] = '/';
char *q = dir_path; temp[len + 1] = '\0';
len++;
// 提取目录部分 }
while (*p != '\0') {
*q = *p; for (size_t i = 1; i < len; i++) {
if (*p == '/' && *(p+1) != '\0') { if (temp[i] == '/') {
// 检查并创建每一级目录 temp[i] = '\0';
if (access(dir_path, F_OK) != 0) { if (access(temp, F_OK) != 0) {
if (mkdir(dir_path, 0755) != 0) { if (mkdir(temp, 0755) != 0) {
fprintf(stderr, "Failed to create directory: %s\n", dir_path); my_zlog_error("创建目录失败: %s (%s)", temp, strerror(errno));
my_zlog_error("创建目录失败");
return -1; return -1;
} else {
my_zlog_debug("已创建目录: %s", temp);
} }
} }
temp[i] = '/';
} }
p++;
q++;
} }
return 0; return 0;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "mqtt.h" #include "mqtt.h"
#include "warm.h" #include "warm.h"
#include "fileopen.h" #include "fileopen.h"
#include "device_change.h"
#include "judg.h" #include "judg.h"
struct mosquitto *mosq; struct mosquitto *mosq;
...@@ -43,9 +44,6 @@ char *glon=NULL;//加入gps后删除,心跳预留,不更改 ...@@ -43,9 +44,6 @@ char *glon=NULL;//加入gps后删除,心跳预留,不更改
time_t gStart;//时间戳 time_t gStart;//时间戳
char *gdevice_change_id=NULL;
char *gdevice_change_date=NULL;
int mqtt_init() { int mqtt_init() {
// 初始化 mosquitto 库 // 初始化 mosquitto 库
mosquitto_lib_init(); mosquitto_lib_init();
...@@ -176,7 +174,7 @@ void message_4(cJSON *body, cJSON *pin_setctrl){//message 为4时候 ...@@ -176,7 +174,7 @@ void message_4(cJSON *body, cJSON *pin_setctrl){//message 为4时候
pwm_value(gvalt[1],gvalt[2]); pwm_value(gvalt[1],gvalt[2]);
} }
int device_message(cJSON *json){ int device_message(cJSON *json){//接收到的控制设备的mqtt消息
cJSON *head = cJSON_GetObjectItem(json, "head"); cJSON *head = cJSON_GetObjectItem(json, "head");
cJSON *message_type = cJSON_GetObjectItem(head, "message_type"); cJSON *message_type = cJSON_GetObjectItem(head, "message_type");
...@@ -221,7 +219,7 @@ int device_message(cJSON *json){ ...@@ -221,7 +219,7 @@ int device_message(cJSON *json){
return 0; return 0;
} }
int download_message(cJSON *root){ int download_message(cJSON *root){//接收的下载的mqtt消息
cJSON *down = cJSON_GetObjectItem(root, "down"); cJSON *down = cJSON_GetObjectItem(root, "down");
if (cJSON_IsObject(down)) { if (cJSON_IsObject(down)) {
// 获取 site 对象 // 获取 site 对象
...@@ -254,14 +252,16 @@ int download_message(cJSON *root){ ...@@ -254,14 +252,16 @@ int download_message(cJSON *root){
return 0; return 0;
} }
int device_mqttchange_name(cJSON *device_id){ int device_mqttchange_name(cJSON *device_id){
cJSON *id = cJSON_GetObjectItem(device_id, "id");// 提取ID cJSON *id = cJSON_GetObjectItem(device_id, "id");// 提取ID
cJSON *date = cJSON_GetObjectItem(device_id, "date");// 提取日期 cJSON *date = cJSON_GetObjectItem(device_id, "date");// 提取日期
*gdevice_change_id=id->valuestring; char *device_change_id=id->valuestring;
*gdevice_change_date=date->valuestring; char *device_change_date=date->valuestring;
device_changename_back(device_change_date,device_change_id);
// 输出提取的数据 // 输出提取的数据
printf("设备ID: %s\n", id->valuestring); my_zlog_debug("设备ID: %s", device_change_id);
printf("日期: %s\n", date->valuestring); my_zlog_debug("日期: %s", device_change_date);
return 0; return 0;
} }
...@@ -293,7 +293,7 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag ...@@ -293,7 +293,7 @@ void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto_messag
} else if(cJSON_GetObjectItem(json, "device_id") != NULL) { } else if(cJSON_GetObjectItem(json, "device_id") != NULL) {
cJSON *device_id=cJSON_GetObjectItem(json, "device_id"); cJSON *device_id=cJSON_GetObjectItem(json, "device_id");
device_mqttchange_name(device_id); device_mqttchange_name(device_id);
my_zlog_debug("接收到设备更改"); my_zlog_debug("接收到设备更改");
} else {// 提取 head 对象 } else {// 提取 head 对象
if(download_message(json) != 1) my_zlog_debug("接收到dowwnload下载"); if(download_message(json) != 1) my_zlog_debug("接收到dowwnload下载");
if(device_message(json) != 0) my_zlog_debug("没有接收到控制信息,代码编号:%d",device_message(json)); if(device_message(json) != 0) my_zlog_debug("没有接收到控制信息,代码编号:%d",device_message(json));
......
...@@ -14,7 +14,7 @@ void car0102_calculate_L_R(int angle) {//将角度转化为对应的舵机pwm值 ...@@ -14,7 +14,7 @@ void car0102_calculate_L_R(int angle) {//将角度转化为对应的舵机pwm值
pwmWrite(PWM_PIN_CHANGE,val); pwmWrite(PWM_PIN_CHANGE,val);
} }
void car0102_speed_stop() { void car0102_speed_stop() {
pin_value(26,0); //pin_value(26,0);
pwmWrite(PWM_PIN_SPEED,0); pwmWrite(PWM_PIN_SPEED,0);
car0102_calculate_L_R(90); car0102_calculate_L_R(90);
} }
......
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