srecord  1.65.0
ppb.h
Go to the documentation of this file.
1 //
2 // srecord - Manipulate EPROM load files
3 // Copyright (C) 2011, 2013 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or (at your
8 // option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 // more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef SRECORD_INPUT_FILE_PPB_H
20 #define SRECORD_INPUT_FILE_PPB_H
21 
22 #include <srecord/input/file.h>
23 #include <srecord/record.h>
24 
25 namespace srecord {
26 
27 /**
28  * The input_file_hexdump class is used to represent the processing
29  * required to read in a Stag Prom Programmer binary file.
30  */
32  public input_file
33 {
34 public:
35  /**
36  * The destructor.
37  */
38  virtual ~input_file_ppb();
39 
40  /**
41  * The create class method is used to create new dynamically
42  * allocated instances of this class.
43  *
44  * @param filename
45  * The name of the file to be read.
46  */
47  static pointer create(const std::string &filename);
48 
49 protected:
50  // See base class for documentation.
51  bool read(class record &rec);
52 
53  // See base class for documentation.
54  const char *get_file_format_name(void) const;
55 
56  // See base class for documentation.
57  bool is_binary(void) const;
58 
59  // See base class for documentation.
60  int format_option_number(void) const;
61 
62 private:
63  /**
64  * The constructor.
65  *
66  * @param filename
67  * The name of the file to be read.
68  */
69  input_file_ppb(const std::string &filename);
70 
71  /**
72  * The address instance variable is used to remember the current
73  * address of the next data record. This is set and advanced by
74  * the #read method.
75  */
76  record::address_t address;
77 
78  /**
79  * The data_seen instance variable is used to remember whether or
80  * not any data has been seen in the file. This is used to issue
81  * an error when there is aparrently no data in the file, and this
82  * helps #guess to figure out the file is notof this type.
83  */
84  bool data_seen;
85 
86  /**
87  * The packet_address instance variable is used to remember the
88  * address of the first byte in the most recetly read packet.
89  */
90  unsigned long packet_address;
91 
92  /**
93  * The packet instance variable is used to remember the most recent
94  * #packet_length data bytes read from the file in the most recent packet.
95  */
96  record::data_t packet[65536];
97 
98  /**
99  * The packet_length instance variable is used to remember the
100  * number of data bytes in the #packet array.
101  */
102  size_t packet_length;
103 
104  /**
105  * The packet_used instance variable is used to remember how many
106  * bytes of the most recently read packect have been consumed.
107  */
108  size_t packet_used;
109 
110  /**
111  * The get_packet method is used to read another packet, setting
112  * the #packet and #packet_length and #packet_address and
113  * #packet_used instance variables.
114  */
115  bool get_packet(void);
116 
117  /**
118  * The packet_format_error method is used to issue a #fatal_error
119  * message when a packet is malformed.
120  */
121  void packet_format_error(void);
122 
123  /**
124  * The default constructor. Do not use.
125  */
126  input_file_ppb();
127 
128  /**
129  * The copy constructor. Do not use.
130  */
132 
133  /**
134  * The assignment operator. Do not use.
135  */
136  input_file_ppb &operator=(const input_file_ppb &);
137 };
138 
139 };
140 
141 // vim: set ts=8 sw=4 et :
142 #endif // SRECORD_INPUT_FILE_PPB_H
The input_file_hexdump class is used to represent the processing required to read in a Stag Prom Prog...
Definition: ppb.h:33
int format_option_number(void) const
The format_option_number method is used to obtain the option number, which can then be turned into te...
virtual ~input_file_ppb()
The destructor.
const char * get_file_format_name(void) const
The get_file_format_name method is used to find out the name of the file format being read.
static pointer create(const std::string &filename)
The create class method is used to create new dynamically allocated instances of this class.
bool read(class record &rec)
The read method is used to read one record from the input.
bool is_binary(void) const
The is_binary method is used to to determine whether or not a file format is binary (true) of text (f...
The srecord::input_file class is used to represent an generic input file.
Definition: file.h:37
virtual std::string filename(void) const
The filename method is used to get the name of the input file being processed.
std::shared_ptr< input > pointer
Definition: input.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35
uint8_t data_t
The type of record data values.
Definition: record.h:63
uint32_t address_t
The type of record addresses.
Definition: record.h:58