Hauptseite | Klassenhierarchie | Alphabetische Liste | Auflistung der Klassen | Auflistung der Dateien | Klassen-Elemente

# commandstring.hpp

    00001
    00032 #ifndef COMMANDSTRING_HEADER
    00033    #define COMMANDSTRING_HEADER
    00034
    00035    #include <vector>        // class   vector
    00036    #include <windows.h>     // > windef.h : typedef WORD
    00037    #include <iostream>      // cout, namespace std
    00038
    00039    #include "checksum.hpp"  // class   checksum
    00040
    00041
    00042    // definitions for leading and ending block sequence
    00043
    00044    const unsigned char STX = '\02';
    00045    const unsigned char ETX = '\03';
    00046
    00047    const unsigned int NUM_BYTES_ADDRESS= 2;
    00048    const unsigned int NUM_BYTES_CRC=     2;
    00049
    00050    const unsigned char START_SEQUENCE= STX;
    00051    const unsigned char END_SEQUENCE=   ETX;
    00052
    00053    typedef WORD ADDRESS_TYPE;
    00054
    00059    class CCommandstring
    00060    {
    00061       public:
    00064          enum CmdCode
    00065          {
    00066             READ_EEPROM_DATA_REQ    = 0x01,
    00067             READ_PROGRAM_DATA_REQ   = 0x02,
    00068             READ_RAM_DATA_REQ       = 0x03,
    00069             WRITE_EEPROM_DATA_REQ   = 0x04,
    00070             WRITE_PROGRAM_DATA_REQ  = 0x05,
    00071             WRITE_RAM_DATA_REQ      = 0x06,
    00072             READ_EEPROM_DATA_CNF    = 0x81,
    00073             READ_PROGRAM_DATA_CNF   = 0x82,
    00074             READ_RAM_DATA_CNF       = 0x83,
    00075             WRITE_EEPROM_DATA_CNF   = 0x84,
    00076             WRITE_PROGRAM_DATA_CNF  = 0x85,
    00077             WRITE_RAM_DATA_CNF      = 0x86,
    00078             STATUS_INFO             = 0xff
    00079          };
    00080
    00081          // Defaultconstructor
    00082          //
    00085          CCommandstring() : m_nChecksum( 0 ),
    00086                             m_bUseCrcCheck( false )
    00087          {
    00088             SetCommand(  READ_EEPROM_DATA_REQ );
    00089             SetAddress(  0 );
    00090             SetLength(   0 );
    00091          }
    00092
    00093          virtual ~CCommandstring() {};
    00094
    00095          // SetUseCrcCheck
    00100          void SetUseCrcCheck( bool bUseCrc );
    00101
    00102          // GetCommand
    00107          CmdCode GetCommand( void ) const;
    00108
    00109          // GetAddress
    00114
    00115          WORD GetAddress( void ) const;
    00116
    00117
    00118          // GetLength
    00123
    00124          unsigned int GetLength( void ) const;
    00125
    00126
    00127          // GetData
    00132
    00133          std::vector<unsigned char> GetData( void ) const;
    00134
    00135          // GetCommandString
    00140
    00141          const std::vector<unsigned char>& GetCommandString( void ) const;
    00142
    00143          // SetCommand
    00148
    00149          void SetCommand( const CmdCode nCommand );
    00150
    00151          // SetAddress
    00156
    00157          void SetAddress( const ADDRESS_TYPE nNewAdress );
    00158
    00159
    00160          // SetLength
    00165
    00166          void SetLength( const unsigned int uiLength );
    00167
    00168
    00169          // SetData
    00174
    00175          void SetData( const std::vector<unsigned char>& aucData );
    00176
    00177          // SetCommandString
    00183
    00184          bool SetCommandString( const std::vector<unsigned char>& aucNewCommandstring );
    00185
    00186          // CheckData
    00192
    00193          bool CheckData( void );
    00194
    00195          // BuildString
    00200
    00201          void BuildString( void );
    00202
    00203
    00204          // DebugPrintRoutine
    00211          static void DebugPrintRoutine( const char const * pcName,
    00212                                         const ADDRESS_TYPE nAddress,
    00213                                         const unsigned int uiLength );
    00214
    00215          // DebugPrintRoutine
    00223          static void DebugPrintRoutine( const char const * pcName,
    00224                                         const ADDRESS_TYPE nAddress,
    00225                                         const unsigned int uiLength,
    00226                                         const std::vector<unsigned char>& aucData );
    00227
    00228          // DebugPrintVector
    00233          static void DebugPrintVector( const std::vector<unsigned char>& aucData );
    00234
    00235       protected:
    00236       private:
    00237          unsigned int                 m_uiLength;
    00238          CChecksum                    m_cChecksum;
    00239          CHECKSUM_TYPE                m_nChecksum;
    00240          std::vector<unsigned char>   m_aucBytes;
    00241          CmdCode                      m_nCommand;
    00242          ADDRESS_TYPE                 m_nAddress;
    00243
    00244          bool                         m_bUseCrcCheck;
    00245          std::vector<unsigned char>   m_aucCommandstring;
    00246    };
    00247 #endif