SerialFlags.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2014 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00027 //----------------------------------------------------------------------
00028 #ifndef ICL_COMM_SERIAL_SERIALFLAGS_H_INCLUDED
00029 #define ICL_COMM_SERIAL_SERIALFLAGS_H_INCLUDED
00030 
00031 #ifdef _SYSTEM_WIN32_
00032 #include <Windows.h>
00033 #endif
00034 
00035 #include "icl_comm_serial/ImportExport.h"
00036 
00037 namespace icl_comm {
00038 namespace serial {
00039 
00041 
00044 class ICL_COMM_SERIAL_IMPORT_EXPORT SerialFlags
00045 {
00046 public:
00047 
00048   enum DataBits
00049   {
00050     eDB_5 = 5,
00051     eDB_6 = 6,
00052     eDB_7 = 7,
00053     eDB_8 = 8
00054   };
00055 
00056   enum StopBits
00057   {
00058     eSB_1,
00059     eSB_1P5,
00060     eSB_2
00061   };
00062 
00063   enum Parity
00064   {
00065     eP_NONE,
00066     eP_EVEN,
00067     eP_ODD,
00068     eP_MARK,
00069     eP_SPACE
00070   };
00071 
00072   enum BaudRate
00073   {
00074     eBR_0 = 0,
00075     eBR_50 = 50,
00076     eBR_75 = 75,
00077     eBR_110 = 110,
00078     eBR_134 = 134,
00079     eBR_150 = 150,
00080     eBR_200 = 200,
00081     eBR_300 = 300,
00082     eBR_600 = 600,
00083     eBR_1200 = 1200,
00084     eBR_1800 = 1800,
00085     eBR_2400 = 2400,
00086     eBR_4800 = 4800,
00087     eBR_9600 = 9600,
00088     eBR_19200 = 19200,
00089     eBR_38400 = 38400,
00090     eBR_57600 = 57600,
00091     eBR_115200 = 115200,
00092     eBR_230400 = 230400,
00093     eBR_500000 = 500000,
00094     eBR_921600 = 921600
00095   };
00096 
00097   enum FlowControl
00098   {
00099     eFC_FLOW,
00100     eFC_HAND_SHAKE
00101   };
00102 
00103   enum ModemControlFlags
00104   {
00105     eMCF_NULL = 0x000,
00106     eMCF_DTR = 0x002,
00107     eMCF_RTS = 0x004,
00108     eMCF_UNDEFINED = 0x800
00109   };
00110 
00111   SerialFlags() :
00112     m_data_bits(eDB_8),
00113     m_stop_bits(eSB_1),
00114     m_parity(eP_NONE),
00115     m_baud_rate(eBR_9600),
00116     m_flow_control(eFC_HAND_SHAKE),
00117     m_use_modem_control(true),
00118     m_modem_control_flags(eMCF_UNDEFINED),
00119     m_enable_receiver(false),
00120     m_enable_stop_on_receive(false)
00121   {}
00122 
00123   SerialFlags(DataBits data_bits, Parity parity = eP_NONE, bool use_modem_control = false,
00124                bool enable_receiver = false, bool enable_stop_on_receive = false, ModemControlFlags modem_control_flags = eMCF_UNDEFINED) :
00125     m_data_bits(data_bits),
00126     m_stop_bits(eSB_1),
00127     m_parity(parity),
00128     m_baud_rate(eBR_9600),
00129     m_flow_control(eFC_HAND_SHAKE),
00130     m_use_modem_control(use_modem_control),
00131     m_modem_control_flags(modem_control_flags),
00132     m_enable_receiver(enable_receiver),
00133     m_enable_stop_on_receive(enable_stop_on_receive)
00134   {}
00135 
00136   SerialFlags(BaudRate baud_rate, DataBits data_bits, Parity parity = eP_NONE, bool use_modem_control = false,
00137                bool enable_receiver = false, bool enable_stop_on_receive = false, ModemControlFlags modem_control_flags = eMCF_UNDEFINED) :
00138     m_data_bits(data_bits),
00139     m_stop_bits(eSB_1),
00140     m_parity(parity),
00141     m_baud_rate(baud_rate),
00142     m_flow_control(eFC_HAND_SHAKE),
00143     m_use_modem_control(use_modem_control),
00144     m_modem_control_flags(modem_control_flags),
00145     m_enable_receiver(enable_receiver),
00146     m_enable_stop_on_receive(enable_stop_on_receive)
00147   {}
00148 
00149   SerialFlags(BaudRate baud_rate, Parity parity, DataBits data_bits, StopBits stop_bits,
00150                bool use_modem_control = false, bool enable_receiver = false, bool enable_stop_on_receive = false,
00151                ModemControlFlags modem_control_flags = eMCF_UNDEFINED) :
00152     m_data_bits(data_bits),
00153     m_stop_bits(stop_bits),
00154     m_parity(parity),
00155     m_baud_rate(baud_rate),
00156     m_flow_control(eFC_HAND_SHAKE),
00157     m_use_modem_control(use_modem_control),
00158     m_modem_control_flags(modem_control_flags),
00159     m_enable_receiver(enable_receiver),
00160     m_enable_stop_on_receive(enable_stop_on_receive)
00161   {}
00162 
00163   SerialFlags(const SerialFlags& flags) :
00164     m_data_bits(flags.m_data_bits),
00165     m_stop_bits(flags.m_stop_bits),
00166     m_parity(flags.m_parity),
00167     m_baud_rate(flags.m_baud_rate),
00168     m_flow_control(flags.m_flow_control),
00169     m_use_modem_control(flags.m_use_modem_control),
00170     m_modem_control_flags(flags.m_modem_control_flags),
00171     m_enable_receiver(flags.m_enable_receiver),
00172     m_enable_stop_on_receive(false)
00173   {}
00174 
00175   BaudRate getBaudRate() const { return m_baud_rate; }
00176   DataBits getDataBits() const { return m_data_bits; }
00177   bool enableStopOnReceive() const { return m_enable_stop_on_receive; }
00178   bool enableReceiver() const { return m_enable_receiver; }
00179   FlowControl getFlowControl() const { return m_flow_control; }
00180   Parity getParity() const { return m_parity; }
00181   StopBits getStopBits() const { return m_stop_bits; }
00182   bool useModemControl() const { return m_use_modem_control; }
00183 
00184   void setBaudRate(BaudRate baud_rate) { m_baud_rate = baud_rate; }
00185 
00186   ModemControlFlags getModemControlFlags()const { return m_modem_control_flags; }
00187 
00188 #ifdef _SYSTEM_POSIX_
00189   unsigned long CFlags() const;
00190   static unsigned long CFlags(BaudRate baud_rate);
00191 #endif
00192 #ifdef _SYSTEM_WIN32_
00193   void GetDCB(LPDCB dcb) const;
00194 #endif
00195 
00196 private:
00197   DataBits m_data_bits;
00198   StopBits m_stop_bits;
00199   Parity m_parity;
00200   BaudRate m_baud_rate;
00201   FlowControl m_flow_control;
00202   bool m_use_modem_control;
00203   ModemControlFlags m_modem_control_flags;
00204   bool m_enable_receiver;
00205   bool m_enable_stop_on_receive;
00206 
00207 };
00208 
00209 }
00210 }
00211 
00212 #endif


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:19