Skip to content

Commit d6caa97

Browse files
committed
- framework.py now has a VERSION variable indicating the pyControl version. On connecting to a pyboard the framework version is read by the GUI and displayed in the log. If the framework version does not match the GUI version a message is displayed recomending reloading the framework. The framework version and micropython version are now saved in datafiles.
1 parent e686d52 commit d6caa97

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

com/data_logger.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def open_data_file(self, data_dir, experiment_name, setup_ID, subject_ID, dateti
3535
self.data_file.write('I Task name : {}\n'.format(self.sm_info['name']))
3636
self.data_file.write('I Task file hash : {}\n'.format(self.sm_info['task_hash']))
3737
self.data_file.write('I Setup ID : {}\n'.format(self.setup_ID))
38+
self.data_file.write('I Framework version : {}\n'.format(self.sm_info['framework_version']))
39+
self.data_file.write('I Micropython version : {}\n'.format(self.sm_info['micropython_version']))
3840
self.data_file.write('I Subject ID : {}\n'.format(self.subject_ID))
3941
self.data_file.write('I Start date : ' + datetime_now.strftime('%Y/%m/%d %H:%M:%S') + '\n\n')
4042
self.data_file.write('S {}\n\n'.format(json.dumps(self.sm_info['states'])))

com/pycboard.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from array import array
77
from .pyboard import Pyboard, PyboardError
88
from config.paths import dirs
9+
from config.gui_settings import VERSION
910

1011
# ----------------------------------------------------------------------------------------
1112
# Helper functions.
@@ -81,7 +82,10 @@ def __init__(self, serial_port, baudrate=115200, verbose=True, print_func=print
8182
self.print('Error: Unable to open serial connection.')
8283
return
8384
if self.status['framework']:
84-
self.print('pyControl Framework: OK')
85+
self.print(f'Framework version: {self.framework_version}')
86+
if self.framework_version != VERSION:
87+
self.print('\nThe pyControl framework version on the board does not match the GUI version. '
88+
'It is recommended to reload the pyControl framework to the pyboard to ensure compatibility.')
8589
else:
8690
if self.status['framework'] is None:
8791
self.print('pyControl Framework: Not loaded')
@@ -109,6 +113,10 @@ def reset(self):
109113
self.status['framework'] = None # Framework not installed.
110114
else:
111115
self.status['framework'] = False # Framework import error.
116+
try:
117+
self.framework_version = self.eval('fw.VERSION').decode()
118+
except PyboardError:
119+
self.framework_version = '<1.8'
112120
return error_message
113121

114122
def hard_reset(self, reconnect=True):
@@ -309,7 +317,9 @@ def setup_state_machine(self, sm_name, sm_dir=None, uploaded=False):
309317
'events': events, # {name:ID}
310318
'ID2name': {ID: name for name, ID in {**states, **events}.items()}, # {ID:name}
311319
'analog_inputs': self.get_analog_inputs(), # {name: {'ID': ID, 'Fs':sampling rate}}
312-
'variables': self.get_variables()} # {name: repr(value)}
320+
'variables': self.get_variables(),
321+
'framework_version': self.framework_version,
322+
'micropython_version': self.micropython_version} # {name: repr(value)}
313323
if self.data_logger:
314324
self.data_logger.set_state_machine(self.sm_info)
315325

config/gui_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Graphical user interface settings.
22

3-
VERSION = '1.7.2'
3+
VERSION = '1.8'
44

55
update_interval = 10 # Interval between calls to the GUIs update function (ms).
66

pyControl/framework.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from . import state_machine as sm
44
from . import hardware as hw
55

6+
VERSION = '1.8'
7+
68
class pyControlError(BaseException): # Exception for pyControl errors.
79
pass
810

0 commit comments

Comments
 (0)