00001 #ifndef __FBIO_H__
00002 #define __FBIO_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00044 #include <kaydaradef.h>
00045 #ifndef FBSDK_DLL
00046
00049 #define FBSDK_DLL K_DLLIMPORT
00050 #endif
00051
00052 #include <fbsdk/fbcomponent.h>
00053
00054 #ifdef FBSDKUseNamespace
00055 namespace FBSDKNamespace {
00056 #endif
00057
00059
00062 #define FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT 500 // Millisecs
00063
00065 enum FBParity {
00066 kFBParityNone,
00067 kFBParityOdd,
00068 kFBParityEven
00069 };
00070
00072 enum FBRSType {
00073 kFBRS232,
00074 kFBRS422
00075 };
00077 enum FBCommPortType {
00078 kFBPhysical,
00079 kFBVirtual,
00080 kFBInternal
00081 };
00082
00083
00084 FB_DEFINE_ENUM ( FBSDK_DLL, Parity );
00085 FB_DEFINE_ENUM ( FBSDK_DLL, RSType );
00086 FB_DEFINE_ENUM ( FBSDK_DLL, CommPortType );
00087 FB_DEFINE_COMPONENT ( FBSDK_DLL, CommPort );
00088
00089 __FB_FORWARD( FBCommPort );
00090
00092 class FBSDK_DLL FBCommPort : public FBComponent {
00093 __FBClassDeclare( FBCommPort,FBComponent );
00094 public:
00095
00097 FBCommPort();
00098
00105 bool Read( void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL );
00106
00115 bool ReadBlocking( void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong pTimeOut = FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT);
00116
00123 bool Write( void* lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesWritten=NULL );
00124
00133 bool WriteBlocking( void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesWritten=NULL, kULong pTimeOut = FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT);
00134
00138 bool EmptyBuffer();
00139
00140 FBPropertyInt PortNumber;
00141 FBPropertyString OwnerName;
00142 FBPropertyInt BaudRate;
00143 FBPropertyBool UseHardwareFC;
00144
00145 FBPropertyParity Parity;
00146 FBPropertyInt ByteSize;
00147 FBPropertyInt StopBits;
00148 FBPropertyRSType RSType;
00149 FBPropertyCommPortType CommPortType;
00150
00151 FBPropertyBool Active;
00152 };
00153
00155
00157 __FB_FORWARD( FBPropertyListCommPort );
00159 typedef class FBSDK_DLL FBPropertyBaseList< int > FBPropertyBaseListInt;
00160
00162 class FBSDK_DLL FBPropertyListCommPort : public FBPropertyBaseList< int >
00163 {
00164 public:
00169 virtual int Add ( int pItem );
00174 virtual int Remove ( int pItem );
00178 virtual void RemoveAt( int pIndex );
00183 virtual int operator[](int pIndex);
00187 virtual int GetCount();
00188 };
00189
00191
00194 #define FBTCPIP_DEFAULT_BLOCKING_TIMEOUT 500 // Millisecs
00195
00197 enum FBTCPIPSocketType {
00198 kFBTCPIP_Stream,
00199 kFBTCPIP_DGRAM,
00200 kFBTCPIP_RAW
00201 };
00202
00203 __FB_FORWARD( FBTCPIP );
00204
00206 class FBSDK_DLL FBTCPIP : public FBComponent {
00207 __FBClassDeclare( FBTCPIP,FBComponent );
00208 public:
00210 FBTCPIP();
00211
00219 bool Read( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL );
00220
00230 bool ReadBlocking( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong pTimeOut = FBTCPIP_DEFAULT_BLOCKING_TIMEOUT );
00231
00241 bool ReadDatagram( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong* pAddr=NULL, unsigned short *pPort=NULL );
00242
00250 bool Write( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesWritten=NULL );
00251
00261 bool WriteBlocking( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesToWrite=NULL, kULong pTimeOut = FBTCPIP_DEFAULT_BLOCKING_TIMEOUT );
00262
00272 bool WriteDatagram( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesToWrite, kULong pAddr, unsigned short pPort );
00273
00281 bool CreateSocket( int &pSocket, FBTCPIPSocketType pType, char *pProtocol = "ip", bool pNonBlocking=true );
00282
00289 bool Bind( int &pSocket, kULong pAddr , int pPort=0 );
00290
00297 bool Connect( int &pSocket, char *pAddr, int pPort );
00298
00303 bool CloseSocket( int &pSocket );
00304
00310 int Listen( int pSocket, int pBackLog=1 );
00311
00317 int Accept( int pSocket, kULong *pOutAddr=NULL );
00318
00327 int Select( int pSocket, bool pTestRead, bool pTestWrite, bool pTestError, kULong pTimeOutMilisecond=0 );
00328 };
00329
00330 #ifdef FBSDKUseNamespace
00331 }
00332 #endif
00333
00334
00335 #endif