RS232Device.h
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003  * 
00004  * Copyright (c) 2012 
00005  * 
00006  * SCHUNK GmbH & Co. KG
00007  *  
00008  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00009  * 
00010  * Project name: Drivers for "Amtec M5 Protocol" Electronics V4
00011  *                                                                        
00012  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00013  * 
00014  * Email:robotics@schunk.com
00015  * 
00016  * ToDo: 
00017  * 
00018  * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
00019  * 
00020  * Redistribution and use in source and binary forms, with or without 
00021  * modification, are permitted provided that the following conditions are met: 
00022  * 
00023  *  * Redistributions of source code must retain the above copyright 
00024  *    notice, this list of conditions and the following disclaimer. 
00025  *  * Redistributions in binary form must reproduce the above copyright 
00026  *    notice, this list of conditions and the following disclaimer in the 
00027  *    documentation and/or other materials provided with the distribution. 
00028  *  * Neither the name of SCHUNK GmbH & Co. KG nor the names of its 
00029  *    contributors may be used to endorse or promote products derived from 
00030  *    this software without specific prior written permission. 
00031  * 
00032  * This program is free software: you can redistribute it and/or modify 
00033  * it under the terms of the GNU Lesser General Public License LGPL as 
00034  * published by the Free Software Foundation, either version 3 of the 
00035  * License, or (at your option) any later version. 
00036  * 
00037  * This program is distributed in the hope that it will be useful, 
00038  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00039  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00040  * GNU Lesser General Public License LGPL for more details. 
00041  * 
00042  * You should have received a copy of the GNU Lesser General Public 
00043  * License LGPL along with this program. 
00044  * If not, see <http://www.gnu.org/licenses/>.
00045  * 
00046  ******************************************************************************/
00047 
00048 
00049 #ifndef CRS232DEVICE_H
00050 #define CRS232DEVICE_H
00051 
00052 // ---- local includes ------------------------------------------------------ ;
00053 
00054 #include "../Device/ProtocolDevice.h"
00055 #include "../Util/StopWatch.h"
00056 
00057 // ---- global includes ----------------------------------------------------- ;
00058 
00059 #ifdef __LINUX__
00060         #include <fcntl.h>
00061         #include <termios.h>    
00062 #endif
00063 #ifdef __QNX__
00064         #include <sys/types.h>
00065         #include <sys/stat.h>
00066         #include <sys/select.h>
00067         #include <fcntl.h>
00068         #include <termios.h>    
00069 #endif
00070 
00071 class CRS232Device : public CProtocolDevice  
00072 {
00073         private:
00074 
00075                 // ---- private data ---------------------------------------------------- ;
00076         
00077                 // ---- private auxiliary functions ------------------------------------- ;
00078 
00079         protected:
00080 
00081                 // ---- protected data -------------------------------------------------- ;
00082 
00083 #if defined (_WIN32)
00084                         HANDLE m_hDevice;
00085 #endif
00086 #if defined(__LINUX__)
00087                         int m_hDevice;
00088 #endif
00089 #if defined (__QNX__)
00090                         int m_hDevice;
00091 #endif
00092                         int m_iDeviceId;
00093                         unsigned long  m_uiBaudRate;    
00094                         unsigned long m_uiTimeOut;
00095                         CStopWatch m_clTimer;
00096 
00097                 // ---- protected auxiliary functions ----------------------------------- ;
00098 
00099                         int getDeviceError(int iErrorState);
00100                         int setBaudRate();
00101                         int setMessageId(unsigned long uiMessageId);
00102                         int clearReadQueue();
00103                         int reinit(unsigned char ucBaudRateId);
00104                         int readDevice(CProtocolMessage& rclProtocolMessage);
00105                         int writeDevice(CProtocolMessage& rclProtocolMessage);
00106 
00107         public:
00108 
00109                 // ---- public data ----------------------------------------------------- ;
00110 
00111 
00112         
00113                 // ---- constructors / destructor --------------------------------------- ;
00114 
00116                         CRS232Device();
00118                         CRS232Device(const CRS232Device& rclRS232Device);
00120                         virtual ~CRS232Device();
00121 
00122                 // ---- operators ------------------------------------------------------- ;
00123                 
00124                         // assignment operator
00125                         CRS232Device& operator=(const CRS232Device& rclRS232Device);
00126 
00127                 // ---- query functions ------------------------------------------------- ;
00128 
00129                 // ---- modify functions ------------------------------------------------ ;
00130                         
00131                         void setQueueSize(unsigned short uiQueueSize);
00132                         void setTimeOut(unsigned long uiTimeOut);
00133 
00134                 // ---- I/O functions --------------------------------------------------- ;
00135 
00136                 // ---- exec functions -------------------------------------------------- ;
00137 
00138                         int init();
00139                         int init(const char* acInitString);
00140                         int exit();
00141 };
00142 
00143 #endif


schunk_libm5api
Author(s): Florian Weisshardt
autogenerated on Mon Oct 6 2014 07:30:34