Subversion Repositories HomeAutomation

Rev

Rev 1987 | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
1642 runge 1
/*
1987 runge 2
 *
1642 runge 3
 *  Copyright (C) 2010  Mattias Runge
1987 runge 4
 *
1642 runge 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.
1987 runge 9
 *
1642 runge 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.
1987 runge 14
 *
1642 runge 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.
1987 runge 18
 *
1642 runge 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
 
30
namespace atom {
31
namespace control {
32
 
33
class Code
34
{
35
public:
1987 runge 36
  typedef boost::shared_ptr<Code> Pointer;
37
 
38
  Code();
39
  virtual ~Code();
40
 
41
  bool LoadIntelHexFile(std::string filename);
42
  bool ParseIntelHex(std::string data);
43
 
44
  unsigned int GetAddressLower();
45
  unsigned int GetAddressUpper();
46
  unsigned char GetByte(unsigned int address);
47
  unsigned int GetChecksum();
48
  unsigned int GetLength();
49
  bool IsValid();
2005 runge 50
  void Reset(bool fill);
1987 runge 51
  void AddByte(unsigned char byte);
52
 
1642 runge 53
private:
1987 runge 54
  common::Byteset data_;
55
  bool            is_valid_;
56
  unsigned int    address_lower_;
57
  unsigned int    address_upper_;
58
  unsigned int    checksum_;
59
 
60
  void CalculateChecksum();
1642 runge 61
};
62
 
63
}; // namespace control
64
}; // namespace atom
65
 
66
#endif // CONTROL_CODE_H