Skip to content

Commit 6d28653

Browse files
authored
Merge pull request #146 from sparkfun/Update_U-blox_GUI
Add checkboxes for safeboot and training sequence etc.
2 parents eaeff51 + 7c8cd5f commit 6d28653

File tree

2 files changed

+79
-7
lines changed

2 files changed

+79
-7
lines changed

u-blox_Update_GUI/RTK_u-blox_Update_GUI.py

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
This is to avoid you accidentally updating a NEO-D9S with ZED-F9P firmware and vice versa.
66
(Don't worry if that happens. You can recover. But you need access to the SafeBoot pin to
77
force the module into a safe state for re-updating.)
8+
If you _really_ know what you are doing, you can disable this check with the "Override" option.
89
910
ubxfwupdate.exe is a Windows executable. This tool will only work on Windows. Sorry about that.
1011
@@ -26,9 +27,9 @@
2627
RTK_u-blox_Update_GUI.py (this file!)
2728
RTK.ico (icon file for the .exe)
2829
RTK.png (icon for the GUI widget)
29-
ubxfwupdate.exe (copied from u-center)
30-
libMPSSE.dll (copied from u-center)
31-
flash.xml (copied from u-center)
30+
ubxfwupdate.exe (copied from u-center v22.02)
31+
libMPSSE.dll (copied from u-center v22.02)
32+
flash.xml (copied from u-center v22.02)
3233
3334
MIT license
3435
@@ -41,7 +42,8 @@
4142
from PyQt5.QtCore import QSettings, QProcess, QTimer, Qt, QIODevice, pyqtSlot
4243
from PyQt5.QtWidgets import QWidget, QLabel, QComboBox, QGridLayout, \
4344
QPushButton, QApplication, QLineEdit, QFileDialog, QPlainTextEdit, \
44-
QAction, QActionGroup, QMenu, QMenuBar, QMainWindow, QMessageBox
45+
QAction, QActionGroup, QMenu, QMenuBar, QMainWindow, QMessageBox, \
46+
QCheckBox
4547
from PyQt5.QtGui import QCloseEvent, QTextCursor, QIcon, QFont
4648
from PyQt5.QtSerialPort import QSerialPortInfo, QSerialPortInfo
4749

@@ -133,11 +135,39 @@ def __init__(self, parent: QWidget = None) -> None:
133135
self.upload_btn.setFont(myFont)
134136
self.upload_btn.clicked.connect(self.on_upload_btn_pressed)
135137

138+
# Packet Dump Button
139+
self.packet_dump_btn = QCheckBox(self.tr('Packet Dump'))
140+
self.packet_dump_btn.setChecked(False)
141+
142+
# Safeboot Button
143+
self.safeboot_btn = QCheckBox(self.tr('Enter Safeboot'))
144+
self.safeboot_btn.setChecked(True)
145+
self.safeboot_btn.toggled.connect(lambda:self.button_state(self.safeboot_btn))
146+
147+
# Training Button
148+
self.training_btn = QCheckBox(self.tr('Training Sequence'))
149+
self.training_btn.setChecked(True)
150+
151+
# Reset After Button
152+
self.reset_btn = QCheckBox(self.tr('Reset After'))
153+
self.reset_btn.setChecked(True)
154+
155+
# Chip Erase Button
156+
self.chip_erase_btn = QCheckBox(self.tr('Chip Erase'))
157+
self.chip_erase_btn.setChecked(False)
158+
159+
# Override Button
160+
self.override_btn = QCheckBox(self.tr('Override'))
161+
self.override_btn.setChecked(False)
162+
self.override_btn.toggled.connect(lambda:self.button_state(self.override_btn))
163+
136164
# Messages Bar
137165
self.messages_label = QLabel(self.tr('Status / Warnings:'))
138166

139167
# Messages Window
168+
messageFont=QFont("Courier")
140169
self.messageBox = QPlainTextEdit()
170+
self.messageBox.setFont(messageFont)
141171

142172
# Arrange Layout
143173
layout = QGridLayout()
@@ -159,15 +189,34 @@ def __init__(self, parent: QWidget = None) -> None:
159189
layout.addWidget(self.baud_combobox, 4, 1)
160190
layout.addWidget(self.upload_btn, 4, 2)
161191

162-
layout.addWidget(self.messages_label, 5, 0)
163-
layout.addWidget(self.messageBox, 6, 0, 5, 4)
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)
198+
199+
layout.addWidget(self.messages_label, 9, 0)
200+
layout.addWidget(self.messageBox, 10, 0, 5, 4)
164201

165202
self.setLayout(layout)
166203

167204
self.settings = QSettings()
168205
#self._clean_settings() # This will delete all existing settings! Use with caution!
169206
self._load_settings()
170207

208+
def button_state(self, b) -> None:
209+
if b.text() == "Safeboot":
210+
if b.isChecked() == True:
211+
self.training_btn.setChecked(True)
212+
self.training_btn.setEnabled(True)
213+
else:
214+
self.training_btn.setChecked(False)
215+
self.training_btn.setEnabled(False)
216+
elif b.text() == "Override":
217+
if b.isChecked() == True:
218+
self.show_error_message(">>>>> Override enabled <<<<<\nFirmware version check is disabled")
219+
171220
def writeMessage(self, msg) -> None:
172221
self.messageBox.moveCursor(QTextCursor.End)
173222
self.messageBox.ensureCursorVisible()
@@ -424,7 +473,8 @@ def on_upload_btn_pressed(self) -> None:
424473
if endPos >= 0:
425474
self.writeMessage(printable[startPos : endPos]) # Print the full product version
426475

427-
if 1: # Change this to 0 for "god mode" (always update - even if fwver does not match)
476+
if self.override_btn.isChecked() == False:
477+
428478
if fwver == '':
429479
self.writeMessage("Unable to read the receiver and software version. Aborting...")
430480
return
@@ -436,13 +486,35 @@ def on_upload_btn_pressed(self) -> None:
436486
self.writeMessage("\nThe firmware appears invalid for this module. Aborting...")
437487
return
438488

489+
self.override_btn.setChecked(False)
490+
439491
self.writeMessage("\nUpdating firmware\n")
440492

441493
command = []
442494
command.extend(["-p",self.port])
443495
command.extend(["-b",self.baudRate + ":" + self.baudRate + ":115200"])
444496
if self.fisLocation_lineedit.text() != '':
445497
command.extend(["-F", self.theFisName])
498+
if self.packet_dump_btn.isChecked() == True:
499+
command.extend(["-v","2"])
500+
else:
501+
command.extend(["-v","1"])
502+
if self.safeboot_btn.isChecked() == True:
503+
command.extend(["-s","1"])
504+
if self.training_btn.isChecked() == True:
505+
command.extend(["-t","1"])
506+
else:
507+
command.extend(["-t","0"])
508+
else:
509+
command.extend(["-s","0"])
510+
if self.reset_btn.isChecked() == True:
511+
command.extend(["-R","1"])
512+
else:
513+
command.extend(["-R","0"])
514+
if self.chip_erase_btn.isChecked() == True:
515+
command.extend(["-C","1"])
516+
else:
517+
command.extend(["-C","0"])
446518
command.append(self.theFirmwareName)
447519

448520
self.writeMessage("ubxfwupdate.exe %s\n\n" % " ".join(command))
Binary file not shown.

0 commit comments

Comments
 (0)