|
TUsb Respiration Belt plugin 1.0
|
00001 #ifndef LSERIE_H 00002 #define LSERIE_H 00003 00004 #include <string> 00005 #include <sstream> 00006 #include <list> 00007 #include <windows.h> 00008 #include <scol.h> 00009 00010 #define DISCONNECTION_WIN_TIME 1000 00011 00012 using namespace std; 00013 00014 class LSerie 00015 { 00016 public: 00017 //------ CONSTRUCTOR ------ 00018 LSerie(); 00019 virtual ~LSerie(); 00020 00021 int currentPort; 00022 00023 HANDLE comport; 00024 00025 //------ OPEN AND CONFIGURE ------ 00026 bool CheckPort(unsigned int num); 00027 bool open(int numPort, long speedInBaud); //Open the serial port COM "numPort" at the speed "speedInBaud". 00028 // bauds with and this adjustement : 8 bit / 1 stop bit / no parity). 00029 // Return: true if success. 00030 bool open(int numPort, long speedInBaud, //Open the serial port COM "numPort" at the speed "speedInBaud". 00031 int nbBit, int parity, float nbStopBit); // bauds with and this adjustement : "nbBit" bit / "nbStopBit" stop bit / "parity"). 00032 // Return: true if success. 00033 void closeCom(); //Close the serial port. 00034 bool setTimeOut(DWORD ms); //Set the time-out for receive data. Return: true if success. 00035 bool setSpeed(DWORD baudrate); //Set the speed in bauds. Return: true if success. 00036 00037 //------ SEND AND RECEIVE DATA ------ 00038 int sendData(DWORD lg, LPBYTE data); //Send table "data" of "lg" bytes. Return: number of bytes really sent. 00039 int sendData(string* data); //Send string "data". Return: number of bytes really sent. 00040 int receiveData(DWORD lg, LPBYTE data); //Receive table "data" who is limit at "lg" bytes. Return: number of bytes received. 00041 int receiveData(string* data); //Receive string "data". Return: number of bytes received. 00042 00043 //------ READ AND WRITE THE STATE OF THE CONTROL LINE ------ 00044 bool setRts(bool val); // Set the state of RTS. Return: true if success. 00045 bool setDtr(bool val); // Set the state of DTR. Return: true if success. 00046 bool setTxd(bool val); // Set the state of TXD. Return: true if success. 00047 bool getCts(); // Return: The state of CTS. 00048 bool getDtr(); // Return: The state of DTR. 00049 bool getRi(); // Return: The state of RI. 00050 bool getCd(); // Return: The state of CD. 00051 bool isConnect(); 00052 00053 static std::list<unsigned int> enumAvailablePorts(); 00054 00055 string getErrorMsg(); // Return: The error message generated by the last function. 00056 00057 private: 00058 HANDLE hcom; //Fichier de sortie sur le port COM | The file stream use for acces to the serial port. 00059 _COMMTIMEOUTS ct; //={0,0,0,0,0}; //Config du Time Out | This variable contain the delay of the time-out. 00060 DCB dcb; //Config du Port | This object is use in order to configure the serial port. 00061 int bufferSize; 00062 //?????????????????????????????? 00063 COMMTIMEOUTS CommTimeouts; 00064 }; 00065 00066 00067 template<typename T> 00068 inline bool valueOf(const std::string &s, T &obj) 00069 { 00070 std::istringstream is(s); 00071 return is >> obj; 00072 } 00073 00074 #endif 00075
1.7.3