INNER CODE UNIT · Python
rtc
polhenarejos/pico-hsm · tools/pico-hsm-tool.py:263
def rtc(picohsm, args):
if (args.subcommand == 'set'):
now = datetime.now()
_ = picohsm.send(cla=0x80, command=0x64, p1=0x0A, data=list(now.year.to_bytes(2, 'big')) + [now.month, now.day, now.weekday(), now.hour, now.minute, now.second ])
elif (args.subcommand == 'get'):
response = picohsm.send(cla=0x80, command=0x64, p1=0x0A)
dt = datetime(int.from_bytes(response[:2], 'big'), response[2], response[3], response[5], response[6], response[7])
print(f'Current date and time is: {dt.ctime()}')
def opts(picohsm, args):
opt = 0x0
if (args.opt == 'button'):
opt = 0x1
elif (args.opt == 'counter'):
opt = 0x2
current = picohsm.send(cla=0x80, command=0x64, p1=0x6)[0]
if (args.subcommand == 'set'):
if (args.onoff == 'on'):