コード例 #1
0
ファイル: test_bulk_notready.py プロジェクト: xross/lib_xud-1
def test_session(ep, address, bus_speed):

    pktLength = 10
    ied = 500

    session = UsbSession(bus_speed=bus_speed,
                         run_enumeration=False,
                         device_address=address)

    session.add_event(
        UsbTransaction(
            session,
            deviceAddress=address,
            endpointNumber=ep,
            endpointType="BULK",
            transType="OUT",
            dataLength=pktLength,
        ))

    # Expect NAK's from DUT
    session.add_event(
        TokenPacket(
            pid=USB_PID["IN"],
            address=address,
            endpoint=ep,
        ))
    session.add_event(RxHandshakePacket(pid=USB_PID["NAK"]))

    session.add_event(
        TokenPacket(
            pid=USB_PID["OUT"],
            address=address,
            endpoint=ep,
            interEventDelay=ied,
        ))

    session.add_event(
        TxDataPacket(
            dataPayload=session.getPayload_out(ep, pktLength),
            pid=USB_PID["DATA0"],
        ))

    session.add_event(RxHandshakePacket(pid=USB_PID["NAK"]))

    return session
コード例 #2
0
def test_session(ep, address, bus_speed):

    session = UsbSession(bus_speed=bus_speed,
                         run_enumeration=False,
                         device_address=address)

    # The large inter-frame gap is to give the DUT time to print its output
    interEventDelay = 500

    # Valid OUT transaction
    session.add_event(
        UsbTransaction(
            session,
            deviceAddress=address,
            endpointNumber=ep,
            endpointType="BULK",
            transType="OUT",
            dataLength=10,
            interEventDelay=interEventDelay,
        ))

    # OUT Transaction with invalid DATA PID. XCORE should ignore packet - no ACK
    session.add_event(
        TokenPacket(
            pid=USB_PID["OUT"],
            address=address,
            endpoint=ep,
            interEventDelay=interEventDelay,
        ))

    session.add_event(
        TxDataPacket(
            dataPayload=session.getPayload_out(ep, 11, resend=True),
            pid=USB_PID["DATA1"] & 0xF,
        ))

    # Send some valid OUT transactions
    session.add_event(
        UsbTransaction(
            session,
            deviceAddress=address,
            endpointNumber=ep,
            endpointType="BULK",
            transType="OUT",
            dataLength=11,
            interEventDelay=interEventDelay,
        ))
    session.add_event(
        UsbTransaction(
            session,
            deviceAddress=address,
            endpointNumber=ep,
            endpointType="BULK",
            transType="OUT",
            dataLength=12,
            interEventDelay=interEventDelay,
        ))
    session.add_event(
        UsbTransaction(
            session,
            deviceAddress=address,
            endpointNumber=ep,
            endpointType="BULK",
            transType="OUT",
            dataLength=13,
            interEventDelay=interEventDelay,
        ))

    return session