Subversion Repositories HomeAutomation

Rev

Rev 1987 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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