-
Notifications
You must be signed in to change notification settings - Fork 1
/
comport.h
60 lines (41 loc) · 1.21 KB
/
comport.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _COMPORT_H
#define _COMPORT_H
#include <termios.h>
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <strings.h>
#include <string.h>
#include "http.h"
#include "cJSON.h"
#define ARRAY_MAX 64
#define CARRIAGE_ID 1
#define LUGGAGE_NUM 8
#define HTTP_POST "http://192.168.1.132:2002/luggage_capacity_info"
typedef struct _comport{
char paritybit;//奇偶检验位
int databit;//数据位
int com_fd;//fd
int baudrate;//波特率
int stopbit;//停止位
int isopen;
char path[ARRAY_MAX];//串口路径
}comport;
comport *initComport();
void comport_term(comport *pcomport);
int openComport(comport *p_comport,struct termios *old_term);
int closeComport(comport *p_comport,struct termios *old_term);
int readComport(int fd,char *buff,int buffsize);
int writeComport(int fd,char *buff,int buffsize);
int setComport(comport *p_comport,struct termios *term);
int readFrame(char *r_buf,int buffsize,char *meg);
int getNoAnsOp(int i);
void sendHttp(char* add,char *meg);
char *createJson(cJSON *carrList,cJSON **res,char *result,int size);
int write_str(char * add,char * str);
#endif