Buffer Interface
BFSerial.h
Go to the documentation of this file.
1 /***************************************************************************
2 *
3 * BFSerial.h
4 *
5 * BitFlow serial interface API
6 *
7 * Function prototypes
8 *
9 * Copyright (C) 2004 by BitFlow, Inc. All Rights Reserved.
10 *
11 * 12/13/2004 sms created
12 *
13 ***************************************************************************/
14 #include "BFDef.h"
15 
16 #ifndef __BFSERIALH__
17 #define __BFSERIALH__
18 
19 #ifndef BFSERIALEXPORT
20  #define BFSERIALEXPORT __declspec(dllexport)
21 #endif
22 
23 #ifndef BFSERIALCC
24  #define BFSERIALCC __cdecl
25 #endif
26 
27 typedef struct _SerialMutexes
28 {
29  HANDLE Open;
30  HANDLE Write;
32 
33 
34 /* Serial Reference Structure */
35 typedef struct _SerRefStruc
36 {
37  Bd hBoard;
38  PBFSIGNAL pCLReadSignal; // Used by the clSerialRead function
39  PBFSIGNAL pBFCLReadSignal; // Used by the BFCLSerialRead function
40  BFU32 serialIndex;
41  HANDLE SharedMap;
42  SerialMutexesPtr SharedMutexes;
43 
45 
46 typedef enum _DataBits
47 {
52 
54 
55 typedef enum _Parity
56 {
60 
61 } Parity, *ParityPtr;
62 
63 typedef enum _StopBits
64 {
68 
70 
71 // BitFlow error codes
72 #define BFCL_ERROR_SERNOTFOUND -1000 // The serial device was not found
73 #define BFCL_ERROR_BRDNOTFOUND -1001 // There are no R2 boards installed
74 #define BFCL_ERROR_BRDOPEN -1002 // Error opening board
75 #define BFCL_ERROR_THRE -1003 // Transmitter Holding Register not empty (THRE)
76 #define BFCL_ERROR_TEMT -1004 // Transmitter not empty (TEMT)
77 #define BFCL_ERROR_FIFO_EN -1005 // FIFO's are not enabled
78 #define BFCL_ERROR_RCVRFIFO -1006 // Error in RCVR FIFO
79 #define BFCL_ERROR_BAUDRATE -1008 // Invalid Buad Rate
80 #define BFCL_ERROR_DATABITS -1009 // Invalid number of data bits
81 #define BFCL_ERROR_PARITY -1010 // Invalid parity parameter
82 #define BFCL_ERROR_15STOP5DATA -1011 // To use 1.5 number of stop bits, 5 data bits must be used.
83 #define BFCL_ERROR_2STOP5DATA -1012 // Can't use 5 data bits with 2 stop bits
84 #define BFCL_ERROR_STOPBITS -1013 // Invalid number of stop bits.
85 #define BFCL_ERROR_NOSIGNAL -1014 // Can't create signal
86 #define BFCL_ERROR_NOSTRUC -1016 // Can't create ref structure
87 #define BFCL_ERROR_NULLPTR -1017 // BFNULL pointer
88 #define BFCL_ERROR_BYTES_AVAIL -1018 // Error getting the number of bytes available in the buffer
89 #define BFCL_ERROR_FLUSH_PORT -1019 // Error flushing the port
90 #define BFCL_ERROR_DATA_IN -1020 // The receive buffer could not be emptied
91 
92 /* WARNINGS */
93 #define BFCL_WARN_SIG_CANCEL -1015 // BFSerialRead signal was cancelled
94 
95 #ifdef __cplusplus
96 extern "C"{
97 #endif
98 
100 clBFSerialSettings(void* serBFRef, unsigned int baudRate,
101  unsigned int dataBits,
102  unsigned int parity,
103  unsigned int stopBits);
104 
106 clBFSerialRead(void* serBFRef, char* buffer, unsigned int* bufferSize );
107 
109 clBFSerialCancelRead(void* serBFRef);
110 
112 clBFGetBaudRate(void* serBFRef, unsigned int* baudRate);
113 
115 clBFSerialInitFromBoardHandle(Bd hBoard, void** serialRefPtr);
116 
118 clBFGetSerialRef(unsigned int portNum, void** serBFRefPtr);
119 
121 clBFGetSerialRefFromBoardHandle(Bd hBoard, void** serBFRefPtr);
122 
124 BFSVersion(PBFU32 pMajorVersion, PBFU32 pMinorVersion);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif
131 
struct _SerialMutexes SerialMutexes
enum _DataBits * DataBitsPtr
unsigned long BFU32
Definition: BFTypeNT.h:55
BFSERIALEXPORT int BFSERIALCC clBFSerialRead(void *serBFRef, char *buffer, unsigned int *bufferSize)
enum _StopBits * StopBitsPtr
Definition: BFSerial.h:67
BFU32 BFRC
Definition: BFType.h:92
Definition: BFSerial.h:48
BFSERIALEXPORT int BFSERIALCC clBFSerialSettings(void *serBFRef, unsigned int baudRate, unsigned int dataBits, unsigned int parity, unsigned int stopBits)
unsigned long * PBFU32
Definition: BFTypeNT.h:55
Definition: BFSerial.h:66
BFSERIALEXPORT int BFSERIALCC clBFGetBaudRate(void *serBFRef, unsigned int *baudRate)
struct _SerialMutexes * SerialMutexesPtr
Definition: BFSerial.h:51
Definition: BFSerial.h:59
Definition: BFSerial.h:65
_StopBits
Definition: BFSerial.h:63
enum _DataBits DataBits
_Parity
Definition: BFSerial.h:55
BFSERIALEXPORT int BFSERIALCC clBFSerialCancelRead(void *serBFRef)
BFSERIALEXPORT int BFSERIALCC clBFGetSerialRefFromBoardHandle(Bd hBoard, void **serBFRefPtr)
#define BFSERIALCC
Definition: BFSerial.h:24
#define BFSERIALEXPORT
Definition: BFSerial.h:20
void *** Bd
Definition: BFType.h:88
struct _SerRefStruc * pSerRefStruc
_DataBits
Definition: BFSerial.h:46
struct _SerRefStruc SerRefStruc
enum _Parity Parity
Definition: BFSerial.h:57
enum _StopBits StopBits
Definition: BFSerial.h:58
BFSERIALEXPORT BFRC BFSERIALCC BFSVersion(PBFU32 pMajorVersion, PBFU32 pMinorVersion)
Definition: BFSerial.h:50
enum _Parity * ParityPtr
BFSERIALEXPORT int BFSERIALCC clBFGetSerialRef(unsigned int portNum, void **serBFRefPtr)
Definition: BFSerial.h:49
BFSERIALEXPORT int BFSERIALCC clBFSerialInitFromBoardHandle(Bd hBoard, void **serialRefPtr)