Main Page | Modules | Class Hierarchy | Class List | File List | Class Members

di_serial_io.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                 di_serial_io.h  -  Functions that deal with input/output
00003                                    to many serial devices.
00004                              -------------------
00005     begin                : Wed Jun 23 2004
00006     author               : Ioan S. Popescu
00007 
00008 Copyright (C) 2004 DATAQ Instruments, Inc. <develop@dataq.com>
00009 
00010 This program is free software; you can redistribute it and/or 
00011 modify it under the terms of the GNU General Public License 
00012 as published by the Free Software Foundation; either 
00013 version 2 of the License, or (at your option) any later 
00014 version.
00015 
00016 This program is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 GNU General Public License for more details.
00020 
00021 You should have received a copy of the GNU General Public License
00022 along with this program; if not, write to the Free Software
00023 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  ***************************************************************************/
00025 
00026 #ifndef DI_SERIAL_IO_H
00027 #define DI_SERIAL_IO_H
00028 
00029 #include <sys/termios.h>  // POSIX terminal control definitions
00030 #include "../constants.h"
00031 #include <sys/types.h>
00032 
00040 
00041 
00046 class di_serial_io
00047 {
00048   public:
00049     di_serial_io();  
00050     ~di_serial_io();  
00051 
00053     const u_int16_t connect(const char *const dev_file, const u_int8_t device);
00055     const u_int16_t disconnect();
00057     const bool is_comm_open();
00059     const bool di_read(u_int8_t *data,
00060                        u_int16_t &amount,
00061                        const u_int8_t packet_len=2); // if zero, no validation
00063     const bool di_send(const u_int8_t *const data,
00064                        u_int16_t &amount,
00065                        const u_int8_t echo=2,
00066                        const u_int8_t retry=4);
00068     const int16_t bytes_in_receive();
00070     void flush_receive();
00071 
00072   private:
00074     const bool di_valid(const u_int8_t *const data, const u_int8_t packet_len);
00076     const bool di_synchronize(u_int8_t *data,
00077                               const u_int8_t data_len,
00078                               const u_int8_t packet_len);
00080     const bool di_echo(const u_int8_t *const expected,
00081                        const u_int8_t amount);
00082 
00083     unsigned int m_baudrate;  
00084     int m_comm_fd;  
00085     struct termios m_old_termios;  
00086     int m_old_tiocm; 
00087     u_int8_t m_timeout; 
00088 };
00089 
00090 #endif
00091 

Generated on Mon Aug 2 09:44:50 2004 for DataqSDK by doxygen 1.3.6