00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Rick L. Vinyard, Jr. * 00003 * rvinyard@cs.nmsu.edu * 00004 * * 00005 * This file is part of the conexus library. * 00006 * * 00007 * The conexus library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU General Public License * 00009 * version 3 as published by the Free Software Foundation. * 00010 * * 00011 * The conexus library is distributed in the hope that it will be * 00012 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty * 00013 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU General Public License * 00017 * along with this software. If not see <http://www.gnu.org/licenses/>. * 00018 ***************************************************************************/ 00019 #ifndef CONEXUSSERIAL_H 00020 #define CONEXUSSERIAL_H 00021 00022 #include <conexus/conexus-config.h> 00023 #include <conexus/filedescriptor.h> 00024 00031 namespace Conexus 00032 { 00033 00043 class Serial : public FileDescriptor 00044 { 00045 protected: 00046 00047 Serial( const std::string& device = std::string(), ReadWrite rwmode = READ_WRITE ); 00048 00049 public: 00050 00051 typedef ConexusPointer<Serial> pointer; 00052 00053 CONEXUS_ENDPOINT_GENERIC_CREATE(); 00054 00055 static Serial::pointer create( const std::string& device = std::string(), ReadWrite rwmode = READ_WRITE ); 00056 00057 virtual ~Serial(); 00058 00060 virtual void open( const std::string& device, ReadWrite rwmode = READ_WRITE_UNCHANGED ) throw ( open_exception ); 00061 00066 virtual void open() throw ( open_exception ); 00067 00068 ReadWrite rw_mode(); 00069 00073 std::string device(); 00074 00087 void set_device( const std::string& device, ReadWrite rwmode = READ_WRITE_UNCHANGED ) throw ( open_exception ); 00088 00089 sigc::signal<void> signal_device_changed(); 00090 00091 #ifdef CONEXUS_HAVE_UDEV 00092 00096 struct Device { 00097 Device(const std::string& n, const std::string& p): 00098 name(n), path(p) { } 00099 std::string name; 00100 std::string path; 00101 }; 00102 00104 typedef std::vector<Device> Devices; 00105 00113 static Devices enumerate_devices(bool include_virtuals=false); 00114 #endif 00115 00116 protected: 00117 std::string m_device; 00118 ReadWrite m_rwmode; 00119 00120 sigc::signal<void> m_signal_device_changed; 00121 }; 00122 00123 } 00124 00125 #endif