srecord  1.65.0
motorola.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 1998, 1999, 2001, 2002, 2005-2008, 2010, 2011 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it 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
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 Lesser General Public License for 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
17 // <http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef SRECORD_OUTPUT_FILE_MOTOROLA_H
21 #define SRECORD_OUTPUT_FILE_MOTOROLA_H
22 
23 #include <srecord/output/file.h>
24 
25 namespace srecord
26 {
27 
28 /**
29  * The srecord::output_file_motorola class is used to represent an output
30  * file which emits Motorola S-Record format.
31  *
32  * @sa
33  * #srecord::output_file_idt,
34  * #srecord::output_file_wilson,
35  */
37  public output_file
38 {
39 public:
40  /**
41  * The destructor.
42  */
44 
45 private:
46  /**
47  * The constructor.
48  *
49  * @param file_name
50  * The file name to open to write data to. The name "-" is
51  * understood to mean the standard output.
52  */
53  output_file_motorola(const std::string &file_name);
54 
55 public:
56  /**
57  * The create class method is used to create new dynamically
58  * allocated instances of this class.
59  *
60  * @param file_name
61  * The file name to open to write data to. The name "-" is
62  * understood to mean the standard output.
63  */
64  static pointer create(const std::string &file_name);
65 
66 protected:
67  // See base class for documentation.
68  void write(const record &);
69 
70  // See base class for documentation.
71  void line_length_set(int);
72 
73  // See base class for documentation.
74  void address_length_set(int);
75 
76  // See base class for documentation.
77  int preferred_block_size_get(void) const;
78 
79  // See base class for documentation.
80  bool preferred_block_size_set(int nbytes);
81 
82  // See base class for documentation.
83  void command_line(arglex_tool *cmdln);
84 
85  // See base class for documentation.
86  const char *format_name(void) const;
87 
88 private:
89  /**
90  * The data_count instance variable is used to remember the total
91  * number of ouput data lines have occurred to date. Ths is used
92  * at the end of the file to emit an S5 record.
93  */
94  unsigned long data_count;
95 
96  /**
97  * The pref_block_size instance variable is used to remember the
98  * preferred number of data bytes (NOT encoded hex characters) to
99  * be placed in each output line.
100  */
101  int pref_block_size;
102 
103  /**
104  * The address_length instance variable is used to remember the
105  * minimum number of address bytes to be emitted into output lines.
106  */
107  int address_length;
108 
109  /**
110  * The address_shift method is used to remember how far to the left
111  * addresses need to be shifted to become byte addresses.
112  * The default is zero (0).
113  *
114  * This is because of some poorly though out "extentions" to this
115  * file format, for 16-bit and 32-bit data busses. I say "poory
116  * thought out" because the no way (zero, zip, nada) of discovering
117  * this just by looking at the data.
118  */
119  int address_shift;
120 
121  /**
122  * The data_count_written instance variable is used to remember
123  * whether or not we have written out the data count record.
124  * Usually this is done with the start arrdess record, but there
125  * are circumstances where it will be needed when the file is
126  * closed.
127  */
128  bool data_count_written;
129 
130  /**
131  * The write_data_count method is used to write out a data count
132  * record, if one is required.
133  */
134  void write_data_count(void);
135 
136  /**
137  * The write_inner method is used to write a line of output.
138  *
139  * @param tag
140  * The tag value at the start of the line. For example, and S1
141  * line would have a tag of 1.
142  * @param address
143  * The address of the first byte of data on the line.
144  * @param address_nbytes
145  * The number of bytes of address to emit.
146  * @param data
147  * The palyload of this line.
148  * @param data_nbytes
149  * The number of bytes of payload.
150  */
151  void write_inner(int tag, unsigned long address, int address_nbytes,
152  const void *data, int data_nbytes);
153 
154  /**
155  * The copy constructor. Do not use.
156  */
158 
159  /**
160  * The assignment operator. Do not use.
161  */
162  output_file_motorola &operator=(const output_file_motorola &);
163 };
164 
165 };
166 
167 #endif // SRECORD_OUTPUT_FILE_MOTOROLA_H
The srecord::arglex_tool is used to parse command line with srec-specific arguments.
Definition: tool.h:41
The srecord::output_file_motorola class is used to represent an output file which emits Motorola S-Re...
Definition: motorola.h:38
int preferred_block_size_get(void) const
The preferred_block_size_get method is used to get the proferred block size of the output fformat.
const char * format_name(void) const
The format_name method is used to obtain the name of this output format.
bool preferred_block_size_set(int nbytes)
The preferred_block_size_set method is is to set a precific number of bytes for the preferred block s...
void address_length_set(int)
The address_length_set method is used to set the minimum number of bytes to be written for addresses ...
void write(const record &)
The write method is used to write a recordonto an output.
virtual ~output_file_motorola()
The destructor.
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
void line_length_set(int)
The set_line_length method is used to set the maximum length of an output line, for those formats for...
void command_line(arglex_tool *cmdln)
The command_line method is used by arglex_srec::get_output when parsing the command line,...
The srecord::output_file class is used to represent a generic output file.
Definition: file.h:35
std::shared_ptr< output > pointer
Definition: output.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35