Loading...
Searching...
No Matches
firmwareUpdate.py
1"""! @example firmwareUpdate.py """
2
3import sys
4from PySide6.QtWidgets import QApplication
5
6from SquidstatPyLibrary import AisDeviceTracker
7from SquidstatPyLibrary import AisInstrumentHandler
8from SquidstatPyLibrary import AisErrorCode
9
10# Define relavant device information, for easy access
11COMPORT = "COM16"
12
13app = QApplication()
14
16
17def onProgressMessage(message):
18 print(message)
19 if message.__contains__("firmware is updated"):
20 app.quit()
21
22
23tracker.firmwareUpdateNotification.connect(onProgressMessage)
24
25
26# Attempt to connect to the device
27error = tracker.connectToDeviceOnComPort(COMPORT)
28if error.value() == AisErrorCode.FirmwareNotSupported:
29 error = tracker.updateFirmwareOnComPort(COMPORT)
30
31 # Some other error occured
32 if error.value() != AisErrorCode.Success:
33 print(f"Error: {error.message()}")
34 sys.exit()
35elif error.value() != AisErrorCode.Success:
36 print(f"Error: {error.message()}")
37 sys.exit()
38else:
39 print("Device is already up to date.")
40 sys.exit()
41
42sys.exit(app.exec())
43
static AisDeviceTracker * Instance()
get the instance of the device tracker.