This repository has been archived by the owner on May 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathframe.h
61 lines (49 loc) · 2 KB
/
frame.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
60
61
#ifndef XBEE_FRAME_H
#define XBEE_FRAME_H
/*
libxbee - a C/C++ library to aid the use of Digi's XBee wireless modules
running in API mode.
Copyright (C) 2009 onwards Attie Grande ([email protected])
libxbee is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libxbee is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
struct xbee_frameInfo {
char active;
unsigned char id;
int retVal;
};
#define XBEE_FRAME_STATUS_SCHEDULED 0x01
#define XBEE_FRAME_STATUS_WAITING 0x02
#define XBEE_FRAME_STATUS_COMPLETE 0x04
#define XBEE_FRAME_STATUS_ABANDONED 0x08
struct xbee_frame {
xsys_sem sem;
struct xbee_con *con;
unsigned char id;
unsigned char retVal;
unsigned char status; /* this used the XBEE_FRAME_STATUS_* bitfield - zero means unused */
#ifdef XBEE_FRAME_TIMEOUT_ENABLED
struct timespec timeout;
#endif
};
struct xbee_frameBlock {
xsys_mutex mutex;
int numFrames;
int lastFrame;
struct xbee_frame frame[0x100]; /* 0x00 - 0xFF */
};
xbee_err xbee_frameBlockAlloc(struct xbee_frameBlock **nfBlock);
xbee_err xbee_frameBlockFree(struct xbee_frameBlock *fBlock);
xbee_err xbee_frameGetID(struct xbee_frameBlock *fBlock, struct xbee_con *con, char abandon);
xbee_err xbee_frameReturnID(struct xbee_frameBlock *fBlock, struct xbee_con *con);
xbee_err xbee_frameWait(struct xbee_frameBlock *fBlock, struct xbee_con *con, unsigned char *retVal, struct timespec *timeout);
xbee_err xbee_framePost(struct xbee_frameBlock *fBlock, unsigned char frameId, unsigned char retVal);
#endif /* XBEE_FRAME_H */