00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00024 #ifndef __EZV24_H__
00025 #define __EZV24_H__ 1
00026 
00027 
00028 #include <stdlib.h>                          
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 #define V24_SZ_PORTNAME 25                   
00043 
00044 
00047 enum __EZV24_ERROR_CODES
00048 {
00050     V24_E_OK=0,
00052     V24_E_ILLPARM,
00054     V24_E_ILLBAUD,
00056     V24_E_ILLDATASZ,
00058     V24_E_ILLPARITY,
00059 
00063     V24_E_ILLHANDLE,
00065     V24_E_ILLTIMEOUT,
00067     V24_E_CREATE_LOCK,
00069     V24_E_OPEN_LOCK,
00071     V24_E_KILL_LOCK,
00073     V24_E_WRITE_LOCK,
00074 
00078     V24_E_LOCK_EXIST,
00080     V24_E_NOMEM,
00082     V24_E_NULL_POINTER,
00084     V24_E_OPEN,
00086     V24_E_READ,
00088     V24_E_WRITE,
00090     V24_E_NOT_INIT,
00091 
00094     V24_E_NO_PROC_FILE,
00096     V24_E_NOT_IMPLEMENTED,
00098     V24_E_TIMEOUT,
00099 
00102     V24_E_DBG_MESSAGES=100,
00103 
00107     V24_E_DBG_STALE_LOCK
00108 };
00109 
00113 enum __EZV24_BAUDRATE
00114 {
00115     V24_B0=0,                           
00116     V24_B50,                            
00117     V24_B75,                            
00118     V24_B110,                           
00119     V24_B134,                           
00120     V24_B150,                           
00121     V24_B200,                           
00122     V24_B300,                           
00123     V24_B600,                           
00124     V24_B1200,                          
00125     V24_B1800,                          
00126     V24_B2400,                          
00127     V24_B4800,                          
00128     V24_B9600,                          
00129     V24_B19200,                         
00130     V24_B38400,                         
00131     V24_B57600,                         
00132     V24_B115200,                        
00133     V24_NUM_BAUDRATES                   
00134 };
00135 
00139 enum __EZV24_DATASIZE
00140 {
00141     V24_5BIT=0,                              
00142     V24_6BIT,                                
00143     V24_7BIT,                                
00144     V24_8BIT,                                
00145     V24_NUM_DATASIZES                        
00146 };
00147 
00148 
00152 enum __EZV24_PARITY_FLAGS
00153 {
00154     V24_NONE=0,                              
00155     V24_EVEN,                                
00156     V24_ODD,                                 
00157     V24_IGNORE                               
00158 };
00159 
00160 
00164 enum __EZV24_OPEN_FLAGS
00165 {
00166     V24_STANDARD    = 0x0000,                
00167     V24_LOCK        = 0x0001,                
00168     V24_NO_DELAY    = 0x0002,                
00169     V24_RTS_CTS     = 0x0004,                
00170     V24_XON_XOFF    = 0x0008,                
00171     V24_DROP_DTR    = 0x0010,                
00172     V24_NON_BLOCK   = 0x0020,                
00173     V24_SYNC        = 0x0040,                
00174     V24_DEBUG_ON    = 0x8000                 
00175 };
00176 
00177 
00180 enum __EZV24_STATUS_FLAGS
00181 {
00182     V24_DSR_LOW=0,                           
00183     V24_DSR_HIGH,                            
00184     V24_CTS_LOW,                             
00185     V24_CTS_HIGH,                            
00186     V24_DSRCTS_UNKNOWN                       
00187 };
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00199 struct __EZV24_PORT_HANDLE
00200 {
00201         int fd;                              
00202         int Errno;                           
00203         int Locked;                          
00204         int lock_fd;                         
00205         int Initialized;                     
00206         char PortName[V24_SZ_PORTNAME+1];    
00207         unsigned int OpenFlags;              
00208         int Baudrate;                        
00209         int Datasize;                        
00210         int Parity;                          
00211         int TimeoutValue;                    
00212 };
00213 
00214 typedef struct __EZV24_PORT_HANDLE v24_port_t;
00215 
00216 
00217 
00218 
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00258 int v24CountPorts ( unsigned long* BitMask );
00259 
00260 
00278 const char* v24PortName ( int PortNo, char* PortName );
00279 
00280 
00281 
00347 v24_port_t* v24OpenPort ( const char* PortName, unsigned int OpenFlags );
00348 
00349 
00359 int v24ClosePort ( v24_port_t *port );
00360 
00361 
00382 int v24SetParameters ( v24_port_t *port, int Baudrate, int Datasize, int Parity );
00383 
00384 
00397 int v24SetStopbits ( v24_port_t *port, int Stops );
00398 
00399 
00400 
00418 int v24SetTimeouts ( v24_port_t *port, int TenthOfSeconds );
00419 
00420 
00437 int v24Getc ( v24_port_t *port );
00438 
00439 
00448 int v24Putc ( v24_port_t *port, unsigned char TheData );
00449 
00450 
00482 int v24Read ( v24_port_t *port, unsigned char* Buffer, size_t Len );
00483 
00484 
00499 int v24Write ( v24_port_t *port, const unsigned char* Buffer, size_t Len  );
00500 
00501 
00528 int v24Gets ( v24_port_t *port, char* Buffer, size_t BuffSize );
00529 
00530 
00548 int v24Puts ( v24_port_t *port, const char* Buffer );
00549 
00550 
00563 int v24HaveData ( v24_port_t *port );
00564 
00565 
00571 int v24FlushRxQueue ( v24_port_t *port );
00572 
00573 
00579 int v24FlushTxQueue ( v24_port_t *port );
00580 
00581 
00589 int v24SetDTR ( v24_port_t *port, int NewState );
00590 
00591 
00606 int v24SetRTS (v24_port_t *port, int NewState );
00607 
00608 
00617 int v24GetDSR ( v24_port_t *port, int *CurrState );
00618 
00619 
00636 int v24GetCTS (v24_port_t *port, int *CurrState );
00637 
00638 
00645 const char* v24QueryPortName ( v24_port_t *port );
00646 
00647 
00655 int v24QueryFileHandle ( v24_port_t *port );
00656 
00657 
00669 int v24QueryErrno ( v24_port_t *port );
00670 
00671 
00672 
00673 #ifdef __cplusplus
00674 };
00675 #endif
00676 
00677 #endif
00678