• R/O
  • SSH
  • HTTPS

avrdude: Commit


Commit MetaInfo

Revision1482 (tree)
Time2020-06-01 23:36:13
Authorgottfried

Log Message

prepared PROGRAMMER for class

Change Summary

Incremental Difference

--- trunk/config.cpp (revision 1481)
+++ trunk/config.cpp (revision 1482)
@@ -62,7 +62,7 @@
6262 AVRPART * current_part;
6363 AVRMEM * current_mem;
6464 std::vector<AVRPART*> part_list;
65-std::vector<PROGRAMMER> programmers;
65+std::vector<PROGRAMMER*>programmers;
6666
6767 int lineno;
6868 const char * infile;
--- trunk/config_gram.y (revision 1481)
+++ trunk/config_gram.y (revision 1482)
@@ -294,7 +294,7 @@
294294 }
295295 remove_programmer(programmers, existing_prog);
296296 }
297- programmers.push_back(*current_prog);
297+ programmers.push_back(current_prog);
298298 // pgm_fill_old_pins(current_prog); // TODO to be removed if old pin data no longer needed
299299 // pgm_display_generic(current_prog, id);
300300 current_prog = NULL;
--- trunk/libavrdude.h (revision 1481)
+++ trunk/libavrdude.h (revision 1482)
@@ -540,6 +540,11 @@
540540
541541 typedef struct programmer_t
542542 {
543+ programmer_t(const programmer_t &rhs);
544+ programmer_t& operator=(const programmer_t &rhs);
545+ programmer_t();
546+ ~programmer_t();
547+
543548 std::string id;
544549 char desc[PGM_DESCLEN];
545550 char type[PGM_TYPELEN];
@@ -634,14 +639,14 @@
634639 void pgm_display_generic_mask(PROGRAMMER * pgm, const char * p, unsigned int show);
635640 void pgm_display_generic(PROGRAMMER * pgm, const char * p);
636641
637-PROGRAMMER *locate_programmer(std::vector<PROGRAMMER> &programmers, const char *configid);
642+PROGRAMMER *locate_programmer(std::vector<PROGRAMMER*> &programmers, const char *configid);
638643
639644 typedef void (*walk_programmers_cb)(const char *name, const char *desc,
640645 const char *cfgname, int cfglineno,
641646 void *cookie);
642-void walk_programmers(const std::vector<PROGRAMMER> &programmers, walk_programmers_cb cb, void *cookie);
647+void walk_programmers(const std::vector<PROGRAMMER*> &programmers, walk_programmers_cb cb, void *cookie);
643648
644-void sort_programmers(std::vector<PROGRAMMER> &programmers);
649+void sort_programmers(std::vector<PROGRAMMER*> &programmers);
645650
646651 //#ifdef __cplusplus
647652 //}
@@ -826,7 +831,7 @@
826831 void walk_programmer_types(walk_programmer_types_cb cb, void *cookie);
827832
828833 // New std::vector lists
829-void remove_programmer(std::vector<PROGRAMMER> &programmers, PROGRAMMER *data_ptr);
834+void remove_programmer(std::vector<PROGRAMMER*> &programmers, PROGRAMMER *data_ptr);
830835
831836
832837 //#ifdef __cplusplus
@@ -836,7 +841,7 @@
836841 /* formerly config.h */
837842
838843 extern std::vector<AVRPART*> part_list;
839-extern std::vector<PROGRAMMER> programmers;
844+extern std::vector<PROGRAMMER*>programmers;
840845 extern char default_programmer[];
841846 extern char default_parallel[];
842847 extern char default_serial[];
--- trunk/main.cpp (revision 1481)
+++ trunk/main.cpp (revision 1482)
@@ -220,7 +220,7 @@
220220 }
221221 }
222222
223-static void list_programmers(FILE *f, const char *prefix, std::vector<PROGRAMMER> &programmers)
223+static void list_programmers(FILE *f, const char *prefix, std::vector<PROGRAMMER*> &programmers)
224224 {
225225 struct list_walk_cookie c;
226226
--- trunk/pgm.cpp (revision 1481)
+++ trunk/pgm.cpp (revision 1482)
@@ -62,81 +62,223 @@
6262 }
6363
6464
65-PROGRAMMER *pgm_new()
65+programmer_t::programmer_t(const programmer_t &rhs) :
66+ //id (""), // empty ID
67+ //port (rhs.port ),
68+ exit_vcc (rhs.exit_vcc ),
69+ exit_reset (rhs.exit_reset ),
70+ exit_datahigh (rhs.exit_datahigh ),
71+ conntype (rhs.conntype ),
72+ ppidata (rhs.ppidata ),
73+ ppictrl (rhs.ppictrl ),
74+ //usbdev (rhs.usbdev ),
75+ //usbsn (rhs.usbsn ),
76+ //usbvendor (rhs.usbvendor ),
77+ //usbproduct (rhs.usbproduct ),
78+ usbvid (rhs.usbvid ),
79+ bitclock (rhs.bitclock ),
80+ ispdelay (rhs.ispdelay ),
81+ fd (rhs.fd ),
82+ page_size (rhs.page_size ),
83+ unlock (rhs.unlock ),
84+ page_erase (rhs.page_erase ),
85+ read_sib (rhs.read_sib ),
86+ print_parms (rhs.print_parms ),
87+ set_sck_period (rhs.set_sck_period ),
88+ setpin (rhs.setpin ),
89+ getpin (rhs.getpin ),
90+ highpulsepin (rhs.highpulsepin ),
91+ parseexitspecs (rhs.parseexitspecs ),
92+ cookie (rhs.cookie ),
93+ flag (rhs.flag ),
94+
95+ //desc (rhs.desc ),
96+ //type (rhs.type ),
97+ //config_file (rhs.config_file),
98+ lineno (rhs.lineno ),
99+ baudrate (rhs.baudrate ),
100+ initpgm (rhs.initpgm ),
101+
102+ initialize (rhs.initialize ),
103+ display (rhs.display ),
104+ enable (rhs.enable ),
105+ disable (rhs.disable ),
106+ powerup (rhs.powerup ),
107+ powerdown (rhs.powerdown ),
108+ program_enable (rhs.program_enable),
109+ chip_erase (rhs.chip_erase ),
110+ open (rhs.open ),
111+ close (rhs.close ),
112+ read_byte (rhs.read_byte ),
113+ write_byte (rhs.write_byte ),
114+
115+ rdy_led (rhs.rdy_led),
116+ err_led (rhs.err_led),
117+ pgm_led (rhs.pgm_led),
118+ vfy_led (rhs.vfy_led),
119+
120+ cmd (rhs.cmd ),
121+ cmd_tpi (rhs.cmd_tpi ),
122+ spi (rhs.spi ),
123+ paged_write (rhs.paged_write ),
124+ paged_load (rhs.paged_load ),
125+ write_setup (rhs.write_setup ),
126+ read_sig_bytes (rhs.read_sig_bytes ),
127+ set_vtarget (rhs.set_vtarget ),
128+ set_varef (rhs.set_varef ),
129+ set_fosc (rhs.set_fosc ),
130+ perform_osccal (rhs.perform_osccal ),
131+ parseextparams (rhs.parseextparams ),
132+ setup (rhs.setup ),
133+ teardown (rhs.teardown )
66134 {
67- PROGRAMMER *pgm = new PROGRAMMER;
68- if(pgm == NULL)
135+ memcpy(port , rhs.port , sizeof(port ) );
136+ memcpy(usbdev , rhs.usbdev , sizeof(usbdev ) );
137+ memcpy(usbsn, rhs.usbsn , sizeof(usbsn ) );
138+ memcpy(usbvendor , rhs.usbvendor , sizeof(usbvendor ) );
139+ memcpy(usbproduct , rhs.usbproduct , sizeof(usbproduct ) );
140+ memcpy(desc , rhs.desc , sizeof(desc ) );
141+ memcpy(type , rhs.type , sizeof(type ) );
142+ memcpy(config_file, rhs.config_file, sizeof(config_file) );
143+
144+ memcpy(pinno, rhs.pinno, sizeof(pinno));
145+ memcpy(pin, rhs.pin, sizeof(pin));
146+}
147+
148+programmer_t& programmer_t::operator=(const programmer_t &rhs)
149+{
150+ if(this != &rhs)
69151 {
70- avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n",
71- progname);
72- return NULL;
73- }
152+ //id = ""; // empty ID
153+ memcpy(port , rhs.port , sizeof(port ) );
154+ exit_vcc = rhs.exit_vcc ;
155+ exit_reset = rhs.exit_reset ;
156+ exit_datahigh = rhs.exit_datahigh ;
157+ conntype = rhs.conntype ;
158+ ppidata = rhs.ppidata ;
159+ ppictrl = rhs.ppictrl ;
160+ memcpy(usbdev , rhs.usbdev , sizeof(usbdev ) );
161+ memcpy(usbsn , rhs.usbsn , sizeof(usbsn ) );
162+ memcpy(usbvendor , rhs.usbvendor , sizeof(usbvendor ) );
163+ memcpy(usbproduct , rhs.usbproduct , sizeof(usbproduct ) );
164+ usbvid = rhs.usbvid ;
165+ bitclock = rhs.bitclock ;
166+ ispdelay = rhs.ispdelay ;
167+ fd = rhs.fd ;
168+ page_size = rhs.page_size ;
169+ unlock = rhs.unlock ;
170+ page_erase = rhs.page_erase ;
171+ read_sib = rhs.read_sib ;
172+ print_parms = rhs.print_parms ;
173+ set_sck_period = rhs.set_sck_period ;
174+ setpin = rhs.setpin ;
175+ getpin = rhs.getpin ;
176+ highpulsepin = rhs.highpulsepin ;
177+ parseexitspecs = rhs.parseexitspecs ;
178+ cookie = rhs.cookie ;
179+ flag = rhs.flag ;
74180
75- //memset(pgm, 0, sizeof(*pgm));
76- pgm->port[0] = 0;
77- pgm->exit_vcc = EXIT_VCC_UNSPEC;
78- pgm->exit_reset = EXIT_RESET_UNSPEC;
79- pgm->exit_datahigh = EXIT_DATAHIGH_UNSPEC;
80- pgm->conntype = CONNTYPE_SERIAL;
81- pgm->ppidata = 0;
82- pgm->ppictrl = 0;
83- pgm->usbdev[0] = 0;
84- pgm->usbvendor[0] = 0;
85- pgm->usbproduct[0] = 0;
86- pgm->usbvid = 0;
87- pgm->bitclock = 0;
88- pgm->ispdelay = 0;
89- pgm->fd.ifd = 0;
90- pgm->fd.pfd = 0;
91- pgm->fd.usb.handle = 0;
92- pgm->fd.usb.rep = 0;
93- pgm->fd.usb.wep = 0;
94- pgm->fd.usb.eep = 0;
95- pgm->fd.usb.max_xfer= 0;
96- pgm->fd.usb.use_interrupt_xfer = 0;
97- pgm->page_size = 0;
98- pgm->unlock = 0;
99- pgm->page_erase = 0;
100- pgm->read_sib = 0;
101- pgm->print_parms = 0;
102- pgm->set_fosc = 0;
103- pgm->set_sck_period = 0;
104- pgm->setpin = 0;
105- pgm->getpin = 0;
106- pgm->highpulsepin = 0;
107- pgm->parseexitspecs = 0;
108- pgm->cookie = 0;
109- pgm->flag = 0;
181+ memcpy(desc , rhs.desc , sizeof(desc ) );
182+ memcpy(type , rhs.type , sizeof(type ) );
183+ memcpy(config_file, rhs.config_file, sizeof(config_file) );
184+ lineno = rhs.lineno ;
185+ baudrate = rhs.baudrate ;
186+ initpgm = rhs.initpgm ;
110187
111- pgm->desc[0] = 0;
112- pgm->type[0] = 0;
113- pgm->config_file[0] = 0;
114- pgm->lineno = 0;
115- pgm->baudrate = 0;
116- pgm->initpgm = NULL;
188+ initialize = rhs.initialize ;
189+ display = rhs.display ;
190+ enable = rhs.enable ;
191+ disable = rhs.disable ;
192+ powerup = rhs.powerup ;
193+ powerdown = rhs.powerdown ;
194+ program_enable = rhs.program_enable;
195+ chip_erase = rhs.chip_erase ;
196+ open = rhs.open ;
197+ close = rhs.close ;
198+ read_byte = rhs.read_byte ;
199+ write_byte = rhs.write_byte ;
117200
118- for(int i = 0; i < N_PINS; i++)
119- {
120- pgm->pinno[i] = 0;
121- pin_clear_all(&(pgm->pin[i]));
201+ rdy_led = rhs.rdy_led;
202+ err_led = rhs.err_led;
203+ pgm_led = rhs.pgm_led;
204+ vfy_led = rhs.vfy_led;
205+
206+ cmd = rhs.cmd ;
207+ cmd_tpi = rhs.cmd_tpi ;
208+ spi = rhs.spi ;
209+ paged_write = rhs.paged_write ;
210+ paged_load = rhs.paged_load ;
211+ write_setup = rhs.write_setup ;
212+ read_sig_bytes = rhs.read_sig_bytes ;
213+ set_vtarget = rhs.set_vtarget ;
214+ set_varef = rhs.set_varef ;
215+ set_fosc = rhs.set_fosc ;
216+ perform_osccal = rhs.perform_osccal ;
217+ parseextparams = rhs.parseextparams ;
218+ setup = rhs.setup ;
219+ teardown = rhs.teardown ;
220+
221+ memcpy(pinno, rhs.pinno, sizeof(pinno));
222+ memcpy(pin, rhs.pin, sizeof(pin));
122223 }
123224
225+ return *this;
226+}
227+
228+programmer_t::programmer_t() :
229+ port (),
230+ pinno (),
231+ pin (),
232+ exit_vcc (EXIT_VCC_UNSPEC),
233+ exit_reset (EXIT_RESET_UNSPEC),
234+ exit_datahigh (EXIT_DATAHIGH_UNSPEC),
235+ conntype (CONNTYPE_SERIAL),
236+ ppidata (0),
237+ ppictrl (0),
238+ usbdev (),
239+ usbsn (),
240+ usbvendor (),
241+ usbproduct (),
242+ usbvid (0),
243+ bitclock (0),
244+ ispdelay (0),
245+ fd (),
246+ page_size (0),
247+ unlock (0),
248+ page_erase (0),
249+ read_sib (0),
250+ print_parms (0),
251+ set_sck_period (0),
252+ setpin (0),
253+ getpin (0),
254+ highpulsepin (0),
255+ parseexitspecs (0),
256+ cookie (0),
257+ flag (0),
258+
259+ desc(),
260+ type(),
261+ config_file(),
262+ lineno (0),
263+ baudrate (0),
264+ initpgm (NULL),
265+
124266 /*
125267 * mandatory functions - these are called without checking to see
126268 * whether they are assigned or not
127269 */
128- pgm->initialize = pgm_default_2;
129- pgm->display = pgm_default_6;
130- pgm->enable = pgm_default_4;
131- pgm->disable = pgm_default_4;
132- pgm->powerup = pgm_default_powerup_powerdown;
133- pgm->powerdown = pgm_default_powerup_powerdown;
134- pgm->program_enable = pgm_default_2;
135- pgm->chip_erase = pgm_default_2;
136- pgm->open = pgm_default_open;
137- pgm->close = pgm_default_4;
138- pgm->read_byte = pgm_default_3;
139- pgm->write_byte = pgm_default_5;
270+ initialize (pgm_default_2),
271+ display (pgm_default_6),
272+ enable (pgm_default_4),
273+ disable (pgm_default_4),
274+ powerup (pgm_default_powerup_powerdown),
275+ powerdown (pgm_default_powerup_powerdown),
276+ program_enable (pgm_default_2),
277+ chip_erase (pgm_default_2),
278+ open (pgm_default_open),
279+ close (pgm_default_4),
280+ read_byte (pgm_default_3),
281+ write_byte (pgm_default_5),
140282
141283 /*
142284 * predefined functions - these functions have a valid default
@@ -143,30 +285,47 @@
143285 * implementation. Hence, they don't need to be defined in
144286 * the programmer.
145287 */
146- pgm->rdy_led = pgm_default_led;
147- pgm->err_led = pgm_default_led;
148- pgm->pgm_led = pgm_default_led;
149- pgm->vfy_led = pgm_default_led;
288+ rdy_led (pgm_default_led),
289+ err_led (pgm_default_led),
290+ pgm_led (pgm_default_led),
291+ vfy_led (pgm_default_led),
150292
151293 /*
152294 * optional functions - these are checked to make sure they are
153295 * assigned before they are called
154296 */
155- pgm->cmd = NULL;
156- pgm->cmd_tpi = NULL;
157- pgm->spi = NULL;
158- pgm->paged_write = NULL;
159- pgm->paged_load = NULL;
160- pgm->write_setup = NULL;
161- pgm->read_sig_bytes = NULL;
162- pgm->set_vtarget = NULL;
163- pgm->set_varef = NULL;
164- pgm->set_fosc = NULL;
165- pgm->perform_osccal = NULL;
166- pgm->parseextparams = NULL;
167- pgm->setup = NULL;
168- pgm->teardown = NULL;
297+ cmd (NULL),
298+ cmd_tpi (NULL),
299+ spi (NULL),
300+ paged_write (NULL),
301+ paged_load (NULL),
302+ write_setup (NULL),
303+ read_sig_bytes (NULL),
304+ set_vtarget (NULL),
305+ set_varef (NULL),
306+ set_fosc (NULL),
307+ perform_osccal (NULL),
308+ parseextparams (NULL),
309+ setup (NULL),
310+ teardown (NULL)
311+{
312+}
169313
314+programmer_t::~programmer_t()
315+{
316+}
317+
318+
319+PROGRAMMER *pgm_new()
320+{
321+ PROGRAMMER *pgm = new PROGRAMMER;
322+ if(pgm == NULL)
323+ {
324+ avrdude_message(MSG_INFO, "%s: out of memory allocating programmer structure\n",
325+ progname);
326+ return NULL;
327+ }
328+
170329 return pgm;
171330 }
172331
@@ -180,17 +339,17 @@
180339 return NULL;
181340 }
182341
183- pgm->id.clear();
342+ //pgm->id.clear();
184343
185344 return pgm;
186345 }
187346
188347 // New std::vector lists
189-void remove_programmer(std::vector<PROGRAMMER> &programmers, PROGRAMMER *data_ptr )
348+void remove_programmer(std::vector<PROGRAMMER*> &programmers, PROGRAMMER *data_ptr )
190349 {
191- for( std::vector<PROGRAMMER>::iterator it = programmers.begin(); it != programmers.end(); ++it )
350+ for( std::vector<PROGRAMMER*>::iterator it = programmers.begin(); it != programmers.end(); ++it )
192351 {
193- PROGRAMMER *p = &(*it);
352+ PROGRAMMER *p = *it;
194353 if(p == data_ptr)
195354 {
196355 programmers.erase(it);
@@ -275,11 +434,11 @@
275434 pgm_display_generic_mask(pgm, p, SHOW_ALL_PINS);
276435 }
277436
278-PROGRAMMER *locate_programmer(std::vector<PROGRAMMER> &programmers, const char *configid)
437+PROGRAMMER *locate_programmer(std::vector<PROGRAMMER*> &programmers, const char *configid)
279438 {
280- for(std::vector<PROGRAMMER>::iterator ln1 = programmers.begin(); ln1 != programmers.end(); ++ln1)
439+ for(std::vector<PROGRAMMER*>::iterator ln1 = programmers.begin(); ln1 != programmers.end(); ++ln1)
281440 {
282- PROGRAMMER *p = &(*ln1);
441+ PROGRAMMER *p = *ln1;
283442 const char *id = p->id.c_str();
284443
285444 if(strcasecmp(configid, id) == 0)
@@ -299,11 +458,11 @@
299458 * . the line number of the config file this programmer has been defined at
300459 * . the "cookie" passed into walk_programmers() (opaque client data)
301460 */
302-void walk_programmers(const std::vector<PROGRAMMER> &programmers, walk_programmers_cb cb, void *cookie)
461+void walk_programmers(const std::vector<PROGRAMMER*> &programmers, walk_programmers_cb cb, void *cookie)
303462 {
304- for(std::vector<PROGRAMMER>::const_iterator ln1 = programmers.cbegin(); ln1 != programmers.cend(); ++ln1)
463+ for(std::vector<PROGRAMMER*>::const_iterator ln1 = programmers.cbegin(); ln1 != programmers.cend(); ++ln1)
305464 {
306- const PROGRAMMER *p = &(*ln1);
465+ const PROGRAMMER *p = *ln1;
307466
308467 cb(p->id.c_str(), p->desc, p->config_file, p->lineno, cookie);
309468 }
@@ -312,10 +471,10 @@
312471 /*
313472 * Compare function to sort the list of programmers
314473 */
315-bool sort_programmer_compare(PROGRAMMER &p1,PROGRAMMER &p2)
474+bool sort_programmer_compare(const PROGRAMMER *p1, const PROGRAMMER *p2)
316475 {
317- const char *id1 = p1.id.c_str();
318- const char *id2 = p2.id.c_str();
476+ const char *id1 = p1->id.c_str();
477+ const char *id2 = p2->id.c_str();
319478
320479 return strncasecmp(id1, id2, AVR_IDLEN) < 0;
321480 }
@@ -323,7 +482,7 @@
323482 /*
324483 * Sort the list of programmers given as "programmers"
325484 */
326-void sort_programmers(std::vector<PROGRAMMER> &programmers)
485+void sort_programmers(std::vector<PROGRAMMER*> &programmers)
327486 {
328487 std::sort(programmers.begin(), programmers.end(), sort_programmer_compare);
329488 }
Show on old repository browser