Logo Search packages:      
Sourcecode: qlandkarte version File versions  Download package


    Copyright (C) 2007 Oliver Eichler oliver.eichler@gmx.de

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA

  Garmin and MapSource are registered trademarks or trademarks of Garmin Ltd.
  or one of its subsidiaries.

#ifndef CSERIAL_H
#define CSERIAL_H

#include <string>
#include <termios.h>
#include <time.h>
#include <sys/types.h>
#include <sys/time.h>
//#include <stdint.h>
#include <ILink.h>
#include "Garmin.h"

namespace Garmin
    /// Garmin's serial protocol
        This should be kept common to all serial devices. However
        if your device does not fit into the protocol implementation
        at all, subclass it and make your fixes.
00042     class CSerial : public ILink
            CSerial(const std::string& port);
            virtual ~CSerial();

            /// see ILink::open()
            void open();
            /// see ILink::close()
            void close();
            /// see ILink::read()
            int read(Packet_t& data);
            /// see ILink::write()
            void write(const Packet_t& data);
            /// sync. up sequence
                This must be called prior to any other request.

                @param responseCount Number of response packets to expect

                @return Actual retrieved number of response packets to product_request
            virtual int syncup(int responseCount = 0);

            int read(char *data);

            const uint16_t getProductId(){return productId;}
            const int16_t  getSoftwareVersion(){return softwareVersion;}
            const std::string& getProductString(){return productString;}

            // in: bitrate, example: 115200
            // returns: 0=success, <0 error
            int setBitrate( uint32_t bitrate);


            int serial_chars_ready( void);
            int serial_read(Packet_t& data);
            void serial_write(const Packet_t& data);

            int serial_check_ack( uint8_t cmd);
            void serial_send_ack( uint8_t cmd);
            void serial_send_nak( uint8_t cmd);

            virtual void debug(const char * mark, const Garmin::Packet_t& data);

            // file descripor for serial port
            int port_fd;
            struct termios gps_ttysave;
            fd_set fds_read;
                                 //typical max response time
            struct timeval typmax_rsptimetv;

            int interface;

            uint16_t productId;
            int16_t  softwareVersion;
            std::string productString;

            std::string port;

#endif                           //CSERIAL_H

Generated by  Doxygen 1.6.0   Back to index