VCOM Linux Driver
Advantech Inc.
Loading...
Searching...
No Matches
vcom_proto.h
Go to the documentation of this file.
1#ifndef __VCOM_PROTO_H
2#define __VCOM_PROTO_H
4 unsigned int p1;
5 unsigned int p2;
6}__attribute__((packed));
9 unsigned int p1;
10 unsigned int p2;
11 char ptr[4];
12}__attribute__((packed));
13
15 unsigned int p1;
16 unsigned int p2;
17 unsigned int uint;
18}__attribute__((packed));
19
21 unsigned int p1;
22 unsigned int p2;
23 unsigned int chflow;
24 unsigned int flowrep;
25 unsigned int xonlimit;
26 unsigned int xofflimit;
27}__attribute__((packed));
28
30 unsigned int p1;
31 unsigned int p2;
32 unsigned char sbit;
33 unsigned char pair;
34 unsigned char dbit;
35// unsigned char resv;
36}__attribute__((packed));
37
38
39#define VCOM_MAGIC (htonl(0x4d414441))
40
42 unsigned int pid;
43 unsigned int tid;
44 unsigned short cmd;
45 unsigned short len;
46}__attribute__((packed));
47
48
49#define vc_pack_size(a) (sizeof(struct vc_proto_hdr) + sizeof(a))
50#define vc_ext_size(a) (sizeof(a) - sizeof(struct vc_attach_param))
51
62
63#define pack_att(a, b) ((a)->attach.b)
64
65
67 STATUS_SUCCESS = 0x00000000,
69 STATUS_DEVICE_BUSY = 0x80000011,
70};
71
83
116
117static inline void vc_init_hdr(struct vc_proto_hdr * hdr, unsigned int tid,
118 unsigned short cmd, unsigned short len)
119{
120 hdr->pid = VCOM_MAGIC;
121 hdr->tid = htonl(tid);
122 hdr->cmd = htons(cmd);
123 hdr->len = htons(len);
124}
125
126
127static inline int vc_check_hdr(struct vc_proto_hdr * hdr, unsigned short cmd, unsigned short len)
128{
129
130 if(hdr->pid != VCOM_MAGIC){
131 printf("wrong pid: %x instead\n", hdr->pid);
132 return -1;
133 }
134 if(hdr->cmd != htons(cmd)){
135 printf("wrong cmd: %x should be %x\n", ntohs(hdr->cmd), cmd);
136 return -1;
137 }
138 if(hdr->len != htons(len)){
139 printf("wrong len: %x should be %x\n", ntohs(hdr->len), len);
140 return -1;
141 }
142
143 return 0;
144}
145#endif
Definition vcom_proto.h:8
unsigned int p2
Definition vcom_proto.h:10
unsigned int p1
Definition vcom_proto.h:9
char ptr[4]
Definition vcom_proto.h:11
Definition vcom_proto.h:20
unsigned int chflow
Definition vcom_proto.h:23
unsigned int p2
Definition vcom_proto.h:22
unsigned int flowrep
Definition vcom_proto.h:24
unsigned int xofflimit
Definition vcom_proto.h:26
unsigned int xonlimit
Definition vcom_proto.h:25
unsigned int p1
Definition vcom_proto.h:21
Definition vcom_proto.h:29
unsigned int p2
Definition vcom_proto.h:31
unsigned char sbit
Definition vcom_proto.h:32
unsigned int p1
Definition vcom_proto.h:30
unsigned char dbit
Definition vcom_proto.h:34
unsigned char pair
Definition vcom_proto.h:33
Definition vcom_proto.h:3
unsigned int p2
Definition vcom_proto.h:5
unsigned int p1
Definition vcom_proto.h:4
Definition vcom_proto.h:14
unsigned int uint
Definition vcom_proto.h:17
unsigned int p2
Definition vcom_proto.h:16
unsigned int p1
Definition vcom_proto.h:15
Definition vcom_proto.h:41
unsigned int pid
Definition vcom_proto.h:42
unsigned short cmd
Definition vcom_proto.h:44
unsigned int tid
Definition vcom_proto.h:43
unsigned short len
Definition vcom_proto.h:45
Definition vcom_proto.h:52
struct vc_attach_data data
Definition vcom_proto.h:56
struct vc_attach_hflow hflow
Definition vcom_proto.h:58
struct vc_attach_lctrl lctrl
Definition vcom_proto.h:59
struct vc_attach_uint uint32
Definition vcom_proto.h:57
struct vc_attach_param param
Definition vcom_proto.h:55
struct vc_proto_hdr hdr
Definition vcom_proto.h:53
union vc_proto_packet::@0 attach
unsigned short cmd
Definition vcom_proto.h:2
unsigned int tid
Definition vcom_proto.h:1
VCOM_IOCTL
Definition vcom_proto.h:85
@ VCOM_IOCTL_GET_MODEMSTATUS
Definition vcom_proto.h:109
@ VCOM_IOCTL_SET_HANDFLOW
Definition vcom_proto.h:108
@ VCOM_IOCTL_GET_BAUD_RATE
Definition vcom_proto.h:103
@ VCOM_IOCTL_SET_BREAK_ON
Definition vcom_proto.h:88
@ VCOM_IOCTL_GET_PROPERTIES
Definition vcom_proto.h:111
@ VCOM_IOCTL_SET_WAIT_MASK
Definition vcom_proto.h:100
@ VCOM_IOCTL_GET_LINE_CONTROL
Definition vcom_proto.h:104
@ VCOM_IOCTL_SET_DTR
Definition vcom_proto.h:93
@ VCOM_IOCTL_IMMEDIATE_CHAR
Definition vcom_proto.h:90
@ VCOM_IOCTL_WAIT_ON_MASK
Definition vcom_proto.h:101
@ VCOM_IOCTL_GET_HANDFLOW
Definition vcom_proto.h:107
@ VCOM_IOCTL_GET_WAIT_MASK
Definition vcom_proto.h:99
@ VCOM_IOCTL_SET_BREAK_OFF
Definition vcom_proto.h:89
@ VCOM_IOCTL_SET_RTS
Definition vcom_proto.h:95
@ VCOM_IOCTL_SET_XOFF
Definition vcom_proto.h:97
@ VCOM_IOCTL_GET_TIMEOUTS
Definition vcom_proto.h:92
@ VCOM_IOCTL_SET_TIMEOUTS
Definition vcom_proto.h:91
@ VCOM_IOCTL_PURGE
Definition vcom_proto.h:102
@ VCOM_IOCTL_CLR_RTS
Definition vcom_proto.h:96
@ VCOM_IOCTL_GET_STATS
Definition vcom_proto.h:113
@ VCOM_IOCTL_CLR_DTR
Definition vcom_proto.h:94
@ VCOM_IOCTL_SET_LINE_CONTROL
Definition vcom_proto.h:87
@ VCOM_IOCTL_GET_COMMSTATUS
Definition vcom_proto.h:110
@ VCOM_IOCTL_SET_CHARS
Definition vcom_proto.h:106
@ VCOM_IOCTL_SET_BAUD_RATE
Definition vcom_proto.h:86
@ VCOM_IOCTL_GET_DTRRTS
Definition vcom_proto.h:112
@ VCOM_IOCTL_CLEAR_STATS
Definition vcom_proto.h:114
@ VCOM_IOCTL_SET_XON
Definition vcom_proto.h:98
@ VCOM_IOCTL_GET_CHARS
Definition vcom_proto.h:105
#define VCOM_MAGIC
Definition vcom_proto.h:39
VCOM_CMD
Definition vcom_proto.h:73
@ VCOM_CMD_DATAREADY
Definition vcom_proto.h:80
@ VCOM_CMD_IOCTL
Definition vcom_proto.h:77
@ VCOM_CMD_CLOSE
Definition vcom_proto.h:75
@ VCOM_CMD_QUEUEFREE
Definition vcom_proto.h:79
@ VCOM_CMD_SHUTDOWN
Definition vcom_proto.h:81
@ VCOM_CMD_WRITE
Definition vcom_proto.h:76
@ VCOM_CMD_CREATE
Definition vcom_proto.h:74
@ VCOM_CMD_CLEANUP
Definition vcom_proto.h:78
enum VCOM_RESP __attribute__
VCOM_RESP
Definition vcom_proto.h:66
@ STATUS_INVALID_PARAMETER
Definition vcom_proto.h:68
@ STATUS_SUCCESS
Definition vcom_proto.h:67
@ STATUS_DEVICE_BUSY
Definition vcom_proto.h:69
unsigned short len
Definition vcom_proto.h:3
struct vc_proto_hdr hdr
Definition vcom_proto.h:0