cbser.h

Go to the documentation of this file.
00001 #ifndef __CBSER_H_
00002 #define __CBSER_H_
00003 
00094 #include "cbthr.h"
00095 #include <wchar.h>
00096 #ifndef FOR_MS_WINDOWS
00097 # include <termios.h>
00098 #endif
00099 
00103 #define CBSTXTLEN 31
00104 
00110 #define DEFAULT_TIMEOUT 2000
00111 
00112 #ifdef __cplusplus
00113 extern "C" {
00114 #endif
00115 
00119 typedef enum {
00121   CBSI_INVALID,
00123   CBSI_BAUDRATE,
00125   CBSI_DATABITS,
00127   CBSI_PARITY,
00129   CBSI_STOPBITS,
00131   CBSI_SERIALPORT,
00133   CBSI_READY
00134 } CBSERINFO;
00135 
00142 typedef void (*t_cbsercb)(const char *, size_t, void *);
00143 
00148 typedef void (*t_cbserinfocb)(const char *, CBSERINFO, void *);
00149  
00150 #ifdef FOR_MS_WINDOWS
00151 
00152 typedef HANDLE t_hcomport;
00153 
00154 typedef struct {
00155   const char *cbtext;
00156   DWORD      setting;
00157 } t_cbserparam;
00158 
00159 #else
00160 
00161 typedef int t_hcomport;
00162 
00163 typedef struct {
00164   const char *cbtext;
00165   int        setting;
00166 } t_cbserparam;
00167 
00168 #endif
00169 
00172 typedef struct {
00175   t_cbthr    hthr;
00178   t_hcomport hcomport;
00190   t_cbsercb   rdCb;
00193   void        *ctx;
00202   short      goon;
00203 } t_comport;
00204 
00209 typedef struct {
00212   t_cbthr  hthr;
00216   t_cbserinfocb cbsicb;
00219   void     *ctx;
00222   short    goon;
00223 } t_cbserinfo;
00224 
00227 extern const t_cbserparam COMSPEEDS[];
00228 
00231 extern const t_cbserparam COMDATABITS[];
00232 
00235 extern const t_cbserparam COMPARITIES[];
00236 
00239 extern const t_cbserparam COMSTOPBITS[];
00240 
00246 extern const char *DEFAULTPORT;
00247 
00250 extern const char *DEFAULTSPEED;
00251 
00254 extern const char *DEFAULTDATABITS;
00255 
00258 extern const char *DEFAULTPARITY;
00259 
00262 extern const char *DEFAULTSTOPBITS;
00263 
00266 extern const int NCOMSPEEDS;
00267 
00270 extern const int NCOMDATABITS;
00271 
00274 extern const int NCOMPARITIES;
00275 
00278 extern const int NCOMSTOPBITS;
00279 
00282 extern const t_hcomport CBINVALIDCOMPORT;
00283 
00291 void cbserinitcom(t_comport *theHandle);
00292 
00300 void cbserinitinfo(t_cbserinfo *theHandle);
00301 
00332 int cbseropen(t_comport          *theHandle,
00333               const char         *aComPort,
00334               const t_cbserparam *aSpeed,
00335               const t_cbserparam *databits,
00336               const t_cbserparam *aParity,
00337               const t_cbserparam *stopbits,
00338               int                aTimeout,
00339               t_cbsercb          rdCb,
00340               void               *aCtx);
00341 
00370 int cbseropenstr(t_comport          *theHandle,
00371                  const char         *aComPort,
00372                  const char         *aSpeed,
00373                  const char         *databits,
00374                  const char         *aParity,
00375                  const char         *stopbits,
00376                  int                aTimeout,
00377                  t_cbsercb          rdCb,
00378                  void               *aCtx);
00379 
00403 int cbseropenwstr(t_comport          *theHandle,
00404                   const wchar_t      *aComPort,
00405                   const wchar_t      *aSpeed,
00406                   const wchar_t      *databits,
00407                   const wchar_t      *aParity,
00408                   const wchar_t      *stopbits,
00409                   int                aTimeout,
00410                   t_cbsercb          rdCb,
00411                   void               *aCtx);
00412 
00420 int cbserwrite(const t_comport *aHandle, const char *aBuf, size_t aLen);
00421 
00429 int cbserclose(t_comport *theHandle);
00430               
00480 int cbserinfo(t_cbserinfo *theHandle, t_cbserinfocb cbsicb, void *aCtx);
00481 
00493 int cbserinfo_end(t_cbserinfo *theHandle, short doStop);
00494 
00495 #ifdef __cplusplus
00496 }
00497 #endif
00498 
00499 #endif /* __CBSER_H_ */
00500 

Generated on Thu Feb 12 11:09:26 2009 for cb by  doxygen 1.4.7