def diff(value):
    """Convert J/K encoding into bits for P/N diff pair.

    >>> diff('KJ_')
    ('010', '100')

    >>> # Convert ACK handshake packet
    >>> p,n = diff('KJKJKJKKJJKJJKKK__J')
    >>> p
    '0101010011011000001'
    >>> n
    '1010101100100111000'
    """
    usbp = ""
    usbn = ""
    for i in range(len(value)):
        v = value[i]
        if v == ' ':
            continue
        elif v == '_':
            # SE0 - both lines pulled low
            usbp += "0"
            usbn += "0"
        elif v == 'J':
            usbp += "1"
            usbn += "0"
        elif v == 'K':
            usbp += "0"
            usbn += "1"
        else:
            assert False, "Unknown value: %s" % v
    return usbp, usbn