Skip to content

Commit 556da3b

Browse files
authored
Handle invalid time value set (#439)
* bumpversion minor * pip deps on toml * remove sps from args in imp recorder * handle invalid binary time value set only sends the time command when the time is gregorian calendar, else raise an exception
1 parent fded05a commit 556da3b

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/explorepy/command.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def __init__(self):
234234
self.opcode = OpcodeID.CMD_SET_EMMC_TIME
235235
from datetime import datetime
236236
now = datetime.now()
237+
if not (2020 < now.year < 2099):
238+
raise ValueError(f"Unsupported year: {now.year}")
237239
date_time = bytes(
238240
[
239241
now.year - 2000,

src/explorepy/explore.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,14 @@ def set_binary_time(self):
662662
Returns:
663663
bool: True for success, False otherwise
664664
"""
665-
cmd = SetBinaryTime()
666-
if self.stream_processor.configure_device(cmd):
667-
logger.info('Device set to current time.')
668-
return True
665+
try:
666+
cmd = SetBinaryTime()
667+
if self.stream_processor.configure_device(cmd):
668+
logger.info('Device set to current time.')
669+
return True
670+
except ValueError as e:
671+
logger.error('Error on setting the binary file time: {}'.format(e))
672+
return False
669673

670674
def reset_soft(self):
671675
"""Reset the device to the default settings

0 commit comments

Comments
 (0)