Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbtq committed Oct 22, 2023
2 parents 5f75de1 + 31064fa commit 94ef10b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
3 changes: 2 additions & 1 deletion user/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ int rov_config_write_json_to_file(cJSON *params)
fp = fopen(CONFIG_FILE_PATH, "wt+");
if(fp == NULL)
{
log_e("error in open config file");
log_e("error in creating config file");
free(temp);
return -1;
}
}
if (fputs(temp, fp) < 0) //写入文件
{
log_e("error in fputs config file");
fclose(fp);
free(temp);
return -1;
}
Expand Down
20 changes: 10 additions & 10 deletions user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include <unistd.h>
#include <sys/stat.h>

extern void rov_init(int debug_mode);
extern void rov_deinit(void);
extern void rov_loop(void);
extern void uvm_init(int debug_mode);
extern void uvm_deinit(void);
extern void uvm_loop(void);

static void exit_rov(int sig)
static void exit_uvm(int sig)
{
printf("info: closing uv-master app...\n");
rov_deinit();
uvm_deinit();
exit(0);
}

Expand All @@ -23,7 +23,7 @@ int main(int argc, char **argv)
exit(0);
}

signal(SIGINT, exit_rov);
signal(SIGINT, exit_uvm);

char * debug_env = getenv("UV_DEBUG");
if (debug_env == NULL) {
Expand All @@ -37,9 +37,9 @@ int main(int argc, char **argv)
close(STDOUT_FILENO);
close(STDERR_FILENO);;

rov_init(0);
uvm_init(0);
for (;;) {
rov_loop();
uvm_loop();
}
}
} else {
Expand All @@ -50,9 +50,9 @@ int main(int argc, char **argv)
" \\___/ \\_/ \\/ \\/\\__,_|___/\\__\\___|_| \n"
" \n");
printf("info: starting uv-master app...\n");
rov_init(1);
uvm_init(1);
for (;;) {
rov_loop();
uvm_loop();
}
}

Expand Down
26 changes: 13 additions & 13 deletions user/main_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by fxf on 23-9-2.
//

#define LOG_TAG "rov.main"
#define LOG_TAG "uvm.main"

#include <elog.h>
#include <stdlib.h>
Expand All @@ -12,22 +12,22 @@
#include "config/config.h"
#include "control/control.h"

rov_info_t rovInfo;
rov_info_t uvmInfo;

/**
* @brief 停止rov服务
* @brief 停止uvm服务
*/
void rov_deinit()
void uvm_deinit()
{
jsonrpc_server_stop();
rov_device_stop(&rovInfo);
rov_device_stop(&uvmInfo);
}

/**
* @brief rov初始化
* @brief uvm初始化
* @param debug_mode 调试模式
*/
void rov_init(bool debug_mode)
void uvm_init(bool debug_mode)
{
if (debug_mode == true)
{
Expand All @@ -44,26 +44,26 @@ void rov_init(bool debug_mode)
elog_start();
}

if (rov_config_init(&rovInfo) < 0)
if (rov_config_init(&uvmInfo) < 0)
exit(-1);

if (jsonrpc_server_run(&rovInfo) < 0)
if (jsonrpc_server_run(&uvmInfo) < 0)
exit(-1);

if (rov_device_run(&rovInfo) < 0)
if (rov_device_run(&uvmInfo) < 0)
{
jsonrpc_server_stop();
exit(-1);
}

if (rov_control_run(&rovInfo) < 0)
if (rov_control_run(&uvmInfo) < 0)
{
rov_deinit();
uvm_deinit();
exit(-1);
}
}

void rov_loop()
void uvm_loop()
{
sleep(1);
}

0 comments on commit 94ef10b

Please sign in to comment.