Go to most recent revision | Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1642 | runge | 1 | /* |
| 2 | * |
||
| 3 | * Copyright (C) 2010 Mattias Runge |
||
| 4 | * |
||
| 5 | * This program is free software; you can redistribute it and/or modify |
||
| 6 | * it under the terms of the GNU General Public License as published by |
||
| 7 | * the Free Software Foundation; either version 2 of the License, or |
||
| 8 | * (at your option) any later version. |
||
| 9 | * |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | * GNU General Public License for more details. |
||
| 14 | * |
||
| 15 | * You should have received a copy of the GNU General Public License along |
||
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | |||
| 21 | #ifndef CONTROL_CODE_H |
||
| 22 | #define CONTROL_CODE_H |
||
| 23 | |||
| 24 | #include <string> |
||
| 25 | |||
| 26 | #include <boost/shared_ptr.hpp> |
||
| 27 | |||
| 28 | #include "common/Byteset.h" |
||
| 29 | #include "logging/Logger.h" |
||
| 30 | |||
| 31 | namespace atom { |
||
| 32 | namespace control { |
||
| 33 | |||
| 34 | class Code |
||
| 35 | { |
||
| 36 | public: |
||
| 37 | typedef boost::shared_ptr<Code> Pointer; |
||
| 38 | |||
| 39 | Code(); |
||
| 40 | virtual ~Code(); |
||
| 41 | |||
| 42 | bool LoadIntelHexFile(std::string filename); |
||
| 43 | bool ParseIntelHex(std::string data); |
||
| 44 | |||
| 45 | unsigned int GetAddressLower(); |
||
| 46 | unsigned int GetAddressUpper(); |
||
| 47 | unsigned char GetByte(unsigned int address); |
||
| 48 | unsigned int GetChecksum(); |
||
| 49 | unsigned int GetLength(); |
||
| 50 | bool IsValid(); |
||
| 51 | void Reset(); |
||
| 52 | void AddByte(unsigned char byte); |
||
| 53 | |||
| 54 | private: |
||
| 55 | common::Byteset data_; |
||
| 56 | bool is_valid_; |
||
| 57 | unsigned int address_lower_; |
||
| 58 | unsigned int address_upper_; |
||
| 59 | unsigned int checksum_; |
||
| 60 | |||
| 61 | logging::Logger LOG; |
||
| 62 | |||
| 63 | |||
| 64 | void CalculateChecksum(); |
||
| 65 | |||
| 66 | }; |
||
| 67 | |||
| 68 | }; // namespace control |
||
| 69 | }; // namespace atom |
||
| 70 | |||
| 71 | #endif // CONTROL_CODE_H |