58
58
SETTING_FIS_LOCATION = 'fis_location'
59
59
SETTING_FIRMWARE_LOCATION = 'firmware_location'
60
60
SETTING_BAUD_RATE = 'baud'
61
+ SETTING_UPDATE_BAUD_RATE = 'update_baud'
61
62
62
63
guiVersion = 'v1.0'
63
64
@@ -108,8 +109,8 @@ def __init__(self, parent: QWidget = None) -> None:
108
109
self .fis_browse_btn .setEnabled (True )
109
110
self .fis_browse_btn .pressed .connect (self .on_browse_fis_btn_pressed )
110
111
111
- # Clear Button
112
- self .clear_fis_btn = QPushButton (self .tr ('Clear ' ))
112
+ # Clear (Default FIS) Button
113
+ self .clear_fis_btn = QPushButton (self .tr ('Default FIS ' ))
113
114
self .clear_fis_btn .clicked .connect (self .on_clear_fis_btn_pressed )
114
115
115
116
# Port Combobox
@@ -122,16 +123,22 @@ def __init__(self, parent: QWidget = None) -> None:
122
123
self .refresh_btn = QPushButton (self .tr ('Refresh' ))
123
124
self .refresh_btn .clicked .connect (self .on_refresh_btn_pressed )
124
125
125
- # Baudrate Combobox
126
- self .baud_label = QLabel (self .tr ('Baud Rate:' ))
126
+ # Current Baudrate Combobox
127
+ self .baud_label = QLabel (self .tr ('Current Baud Rate:' ))
127
128
self .baud_combobox = QComboBox ()
128
129
self .baud_label .setBuddy (self .baud_combobox )
129
- self .update_baud_rates ()
130
+ self .update_baud_rates (self .baud_combobox )
131
+
132
+ # Update Baudrate Combobox
133
+ self .update_baud_label = QLabel (self .tr ('Update Baud Rate:' ))
134
+ self .update_baud_combobox = QComboBox ()
135
+ self .update_baud_label .setBuddy (self .update_baud_combobox )
136
+ self .update_baud_rates (self .update_baud_combobox , 115200 )
130
137
131
138
# Upload Button
132
139
myFont = QFont ()
133
140
myFont .setBold (True )
134
- self .upload_btn = QPushButton (self .tr (' Update Firmware ' ))
141
+ self .upload_btn = QPushButton (self .tr ('Update Firmware' ))
135
142
self .upload_btn .setFont (myFont )
136
143
self .upload_btn .clicked .connect (self .on_upload_btn_pressed )
137
144
@@ -149,13 +156,17 @@ def __init__(self, parent: QWidget = None) -> None:
149
156
self .training_btn .setChecked (True )
150
157
151
158
# Reset After Button
152
- self .reset_btn = QCheckBox (self .tr ('Reset After' ))
159
+ self .reset_btn = QCheckBox (self .tr ('Reset After Update ' ))
153
160
self .reset_btn .setChecked (True )
154
161
155
162
# Chip Erase Button
156
163
self .chip_erase_btn = QCheckBox (self .tr ('Chip Erase' ))
157
164
self .chip_erase_btn .setChecked (False )
158
165
166
+ # No FIS Button
167
+ self .no_fis_btn = QCheckBox (self .tr ('No FIS' ))
168
+ self .no_fis_btn .setChecked (True )
169
+
159
170
# Override Button
160
171
self .override_btn = QCheckBox (self .tr ('Override' ))
161
172
self .override_btn .setChecked (False )
@@ -175,29 +186,33 @@ def __init__(self, parent: QWidget = None) -> None:
175
186
layout .addWidget (self .firmware_label , 1 , 0 )
176
187
layout .addWidget (self .firmwareLocation_lineedit , 1 , 1 )
177
188
layout .addWidget (self .firmware_browse_btn , 1 , 2 )
189
+ layout .addWidget (self .override_btn , 1 , 4 )
178
190
179
191
layout .addWidget (self .fis_label , 2 , 0 )
180
192
layout .addWidget (self .fisLocation_lineedit , 2 , 1 )
181
193
layout .addWidget (self .fis_browse_btn , 2 , 2 )
182
194
layout .addWidget (self .clear_fis_btn , 2 , 3 )
195
+ layout .addWidget (self .no_fis_btn , 2 , 4 )
183
196
184
197
layout .addWidget (self .port_label , 3 , 0 )
185
198
layout .addWidget (self .port_combobox , 3 , 1 )
186
199
layout .addWidget (self .refresh_btn , 3 , 2 )
200
+ layout .addWidget (self .packet_dump_btn , 3 , 4 )
187
201
188
202
layout .addWidget (self .baud_label , 4 , 0 )
189
203
layout .addWidget (self .baud_combobox , 4 , 1 )
190
- layout .addWidget (self .upload_btn , 4 , 2 )
204
+ layout .addWidget (self .safeboot_btn , 4 , 4 )
205
+
206
+ layout .addWidget (self .update_baud_label , 5 , 0 )
207
+ layout .addWidget (self .update_baud_combobox , 5 , 1 )
208
+ layout .addWidget (self .training_btn , 5 , 4 )
191
209
192
- layout .addWidget (self .packet_dump_btn , 4 , 3 )
193
- layout .addWidget (self .safeboot_btn , 5 , 3 )
194
- layout .addWidget (self .training_btn , 6 , 3 )
195
- layout .addWidget (self .reset_btn , 7 , 3 )
196
- layout .addWidget (self .chip_erase_btn , 8 , 3 )
197
- layout .addWidget (self .override_btn , 9 , 3 )
210
+ layout .addWidget (self .chip_erase_btn , 6 , 4 )
211
+ layout .addWidget (self .reset_btn , 7 , 4 )
198
212
199
- layout .addWidget (self .messages_label , 9 , 0 )
200
- layout .addWidget (self .messageBox , 10 , 0 , 5 , 4 )
213
+ layout .addWidget (self .messages_label , 7 , 0 )
214
+ layout .addWidget (self .upload_btn , 7 , 2 , 1 , 2 )
215
+ layout .addWidget (self .messageBox , 8 , 0 , 5 , 5 )
201
216
202
217
self .setLayout (layout )
203
218
@@ -249,20 +264,30 @@ def _load_settings(self) -> None:
249
264
if index > - 1 :
250
265
self .baud_combobox .setCurrentIndex (index )
251
266
267
+ baud = self .settings .value (SETTING_UPDATE_BAUD_RATE )
268
+ if baud is not None :
269
+ index = self .update_baud_combobox .findData (baud )
270
+ if index > - 1 :
271
+ self .update_baud_combobox .setCurrentIndex (index )
272
+
252
273
lastFile = self .settings .value (SETTING_FIRMWARE_LOCATION )
253
274
if lastFile is not None :
254
275
self .firmwareLocation_lineedit .setText (lastFile )
255
276
256
277
lastFile = self .settings .value (SETTING_FIS_LOCATION )
257
278
if lastFile is not None :
258
279
self .fisLocation_lineedit .setText (lastFile )
280
+ if self .theFisName != '' :
281
+ self .no_fis_btn .setChecked (False )
259
282
else :
260
283
self .fisLocation_lineedit .clear ()
284
+ self .no_fis_btn .setChecked (True )
261
285
262
286
def _save_settings (self ) -> None :
263
287
"""Save settings on shutdown."""
264
288
self .settings .setValue (SETTING_PORT_NAME , self .port )
265
289
self .settings .setValue (SETTING_BAUD_RATE , self .baudRate )
290
+ self .settings .setValue (SETTING_UPDATE_BAUD_RATE , self .updateBaudRate )
266
291
self .settings .setValue (SETTING_FIRMWARE_LOCATION , self .theFirmwareName )
267
292
self .settings .setValue (SETTING_FIS_LOCATION , self .theFisName )
268
293
@@ -296,16 +321,19 @@ def update_com_ports(self) -> None:
296
321
if indexOfPrevious > - 1 : # Restore the previous port if it still exists
297
322
self .port_combobox .setCurrentIndex (indexOfPrevious )
298
323
299
- def update_baud_rates (self ) -> None :
324
+ def update_baud_rates (self , comboBox , minBaud = 9600 ) -> None :
300
325
"""Update baud rate list in GUI."""
301
326
# Lowest speed first so code defaults to that
302
327
# if settings.value(SETTING_BAUD_RATE) is None
303
- self .baud_combobox .clear ()
304
- self .baud_combobox .addItem ("9600" , 9600 )
305
- self .baud_combobox .addItem ("38400" , 38400 )
306
- self .baud_combobox .addItem ("115200" , 115200 )
307
- self .baud_combobox .addItem ("230400" , 230400 )
308
- self .baud_combobox .addItem ("460800" , 460800 )
328
+ comboBox .clear ()
329
+ if minBaud <= 9600 :
330
+ comboBox .addItem ("9600" , 9600 )
331
+ if minBaud <= 38400 :
332
+ comboBox .addItem ("38400" , 38400 )
333
+ comboBox .addItem ("115200" , 115200 )
334
+ comboBox .addItem ("230400" , 230400 )
335
+ comboBox .addItem ("460800" , 460800 )
336
+ comboBox .addItem ("921600" , 921600 )
309
337
310
338
@property
311
339
def port (self ) -> str :
@@ -317,6 +345,11 @@ def baudRate(self) -> str:
317
345
"""Return the current baud rate."""
318
346
return str (self .baud_combobox .currentData ())
319
347
348
+ @property
349
+ def updateBaudRate (self ) -> str :
350
+ """Return the update baud rate."""
351
+ return str (self .update_baud_combobox .currentData ())
352
+
320
353
@property
321
354
def theFirmwareName (self ) -> str :
322
355
"""Return the firmware file name."""
@@ -363,10 +396,12 @@ def on_browse_fis_btn_pressed(self) -> None:
363
396
options = options )
364
397
if fileName :
365
398
self .fisLocation_lineedit .setText (fileName )
399
+ self .no_fis_btn .setChecked (False )
366
400
367
401
def on_clear_fis_btn_pressed (self ) -> None :
368
402
"""Clear the FIS filename."""
369
403
self .fisLocation_lineedit .clear ()
404
+ self .no_fis_btn .setChecked (False )
370
405
371
406
def update_finished (self ) -> None :
372
407
"""The update QProcess has finished."""
@@ -495,16 +530,23 @@ def on_upload_btn_pressed(self) -> None:
495
530
self .writeMessage ("\n Updating firmware\n " )
496
531
497
532
command = []
533
+
498
534
command .extend (["-p" ,self .port ])
499
- command .extend (["-b" ,self .baudRate + ":" + self .baudRate + ":115200" ])
500
- if self .fisLocation_lineedit .text () != '' :
501
- command .extend (["-F" , self .theFisName ])
502
- else :
535
+
536
+ command .extend (["-b" ,self .baudRate + ":" + self .baudRate + ":" + self .updateBaudRate ])
537
+
538
+ if self .no_fis_btn .isChecked () == True :
539
+ command .extend (["--no-fis" , "1" ])
540
+ elif self .fisLocation_lineedit .text () == '' :
503
541
command .extend (["-F" , resource_path ("flash.xml" )])
542
+ else :
543
+ command .extend (["-F" , self .theFisName ])
544
+
504
545
if self .packet_dump_btn .isChecked () == True :
505
546
command .extend (["-v" ,"2" ])
506
547
else :
507
548
command .extend (["-v" ,"1" ])
549
+
508
550
if self .safeboot_btn .isChecked () == True :
509
551
command .extend (["-s" ,"1" ])
510
552
if self .training_btn .isChecked () == True :
@@ -513,14 +555,17 @@ def on_upload_btn_pressed(self) -> None:
513
555
command .extend (["-t" ,"0" ])
514
556
else :
515
557
command .extend (["-s" ,"0" ])
558
+
516
559
if self .reset_btn .isChecked () == True :
517
560
command .extend (["-R" ,"1" ])
518
561
else :
519
562
command .extend (["-R" ,"0" ])
563
+
520
564
if self .chip_erase_btn .isChecked () == True :
521
565
command .extend (["-C" ,"1" ])
522
566
else :
523
567
command .extend (["-C" ,"0" ])
568
+
524
569
command .append (self .theFirmwareName )
525
570
526
571
self .writeMessage ("ubxfwupdate.exe %s\n \n " % " " .join (command ))
0 commit comments