def METHOD_NAME(data):
    params = data.split("\0")
    cmd = params.pop(0)
    if cmd == 'info':
        pass
    ### DIRECT pin operations
    elif cmd == 'pm':
        pairs = zip(params[0::2], params[1::2])
        for (pin, mode) in pairs:
            pin = int(pin)
            if mode == 'in':
                log("Pin %d mode INPUT" % pin)
            elif mode == 'out':
                log("Pin %d mode OUTPUT" % pin)
            elif mode == 'pu':
                log("Pin %d mode INPUT_PULLUP" % pin)
            elif mode == 'pd':
                log("Pin %d mode INPUT_PULLDOWN" % pin)
            else:
                log("Unknown pin %d mode: %s" % (pin, mode))
    elif cmd == 'dw':
        pin = int(params.pop(0))
        val = params.pop(0)
        log("Digital write pin %d, value %s" % (pin, val))
    elif cmd == 'aw':
        pin = int(params.pop(0))
        val = params.pop(0)
        log("Analog write pin %d, value %s" % (pin, val))
    elif cmd == 'dr':           # This should read digital pin
        pin = int(params.pop(0))
        log("Digital read pin %d" % pin)
        conn.sendall(hw("dw", pin, 1)) # Send value
    elif cmd == 'ar':           # This should do ADC read
        pin = int(params.pop(0))
        log("Analog read pin %d" % pin)
        conn.sendall(hw("aw", pin, 123)) # Send value
    ### VIRTUAL pin operations
    elif cmd == 'vw':           # This should call user handler
        pin = int(params.pop(0))
        val = params.pop(0)
        log("Virtual write pin %d, value %s" % (pin, val))
    elif cmd == 'vr':           # This should call user handler
        pin = int(params.pop(0))
        log("Virtual read pin %d" % pin)
        conn.sendall(hw("vw", pin, "hello")) # Send value
    else:
        log("Unknown HW cmd: %s" % cmd)