You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.3 KiB
C
66 lines
1.3 KiB
C
#ifndef _COMMON_H
|
|
#define _COMMON_H
|
|
|
|
#include <sys/time.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
#include "cJSON.h"
|
|
|
|
#define MAX_ITEM_LEN 32
|
|
|
|
#define CFG_FILE "dev_desc.json"
|
|
|
|
typedef unsigned int uint32_t;
|
|
typedef unsigned short uint16_t;
|
|
typedef unsigned char uint8_t;
|
|
typedef int int32_t;
|
|
typedef short int16_t;
|
|
|
|
typedef struct
|
|
{
|
|
/* data */
|
|
char port[MAX_ITEM_LEN];
|
|
char addr[MAX_ITEM_LEN];
|
|
char desc[MAX_ITEM_LEN];
|
|
char model[MAX_ITEM_LEN];
|
|
}DEV_DESC_TYPE;
|
|
|
|
typedef struct
|
|
{
|
|
/* data */
|
|
char baud[MAX_ITEM_LEN];
|
|
char bits[MAX_ITEM_LEN];
|
|
char parity[MAX_ITEM_LEN];
|
|
}PORT_CFG_TYPE;
|
|
|
|
typedef struct
|
|
{
|
|
/* data */
|
|
DEV_DESC_TYPE dev_desc;
|
|
PORT_CFG_TYPE port_cfg;
|
|
}DEV_CFG_INFO;
|
|
|
|
typedef struct
|
|
{
|
|
/* data */
|
|
uint32_t cmd;
|
|
uint32_t t;
|
|
uint32_t argv[250];
|
|
}COM_MSG_TYPE;
|
|
|
|
|
|
extern DEV_CFG_INFO dev_cfg;
|
|
|
|
char *get_time_in_json(void);
|
|
char *make_token(char *token,char len);
|
|
char *read_file(char *file_name,int32_t *ret);
|
|
int32_t read_dev_cfg(DEV_CFG_INFO *p);
|
|
cJSON *file_to_json(char *file);
|
|
int split(char *src,const char *separator,char **dest);
|
|
|
|
int32_t save_to_file(char *file,uint32_t pos,uint8_t *buf,uint32_t size);
|
|
int32_t load_from_file(char *file,uint32_t pos,uint8_t *buf,uint32_t size);
|
|
#endif |