INNER CODE UNIT · Python

phy

polhenarejos/pico-hsm · tools/pico-hsm-tool.py:448

def phy(picohsm, args):
    val = args.value if 'value' in args else None
    if (val):
        if (args.subcommand == 'vidpid'):
            sp = val.split(':')
            if (len(sp) != 2):
                print('ERROR: VID/PID have wrong format. Use VID:PID format (e.g. 1234:5678)')
                return
            val = int(sp[0],16).to_bytes(2, 'big') + int(sp[1],16).to_bytes(2, 'big')
        elif (args.subcommand in ['led_gpio', 'led_brightness']):
            if (args.subcommand == 'led_brightness'):
                if (int(val) > 15 or int(val) < 0):
                    print('ERROR: LED brightness must be between 0 and 15.')
                    return
            val = [int(val)]
        elif (args.subcommand in ['wcid', 'led_dimmable']):
            val = val == 'enable'
    ret = picohsm.phy(args.subcommand, val)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…