Beispiel #1
0
        def test_collect_voluntary_ack_within_aggregation(self, llc):
            dlc = [None, None, None, None]
            for i in range(len(dlc)):
                dlc[i] = llc.socket(nfc.llcp.DATA_LINK_CONNECTION)
                llc.setsockopt(dlc[i], nfc.llcp.SO_RCVBUF, 2)
                pdu = nfc.llcp.pdu.ConnectionComplete(32+i, 16+i, 248)
                threading.Timer(0.01, llc.collect).start()
                threading.Timer(0.02, llc.dispatch, (pdu,)).start()
                llc.connect(dlc[i], 16+i)

            llc.send(dlc[0], 230 * b'1', nfc.llcp.MSG_DONTWAIT)
            pdu = nfc.llcp.pdu.Information(33, 17, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[1]) == b'123'
            pdu = nfc.llcp.pdu.Information(34, 18, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[2]) == b'123'
            pdu = nfc.llcp.pdu.Information(35, 19, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[3]) == b'123'
            assert llc.collect() == nfc.llcp.pdu.AggregatedFrame(0, 0, [
                nfc.llcp.pdu.Information(16, 32, 0, 0, 230 * b'1'),
                nfc.llcp.pdu.ReceiveReady(17, 33, 1),
                nfc.llcp.pdu.ReceiveReady(18, 34, 1)
            ])
            assert llc.collect() == nfc.llcp.pdu.ReceiveReady(19, 35, 1)
Beispiel #2
0
        def test_collect_voluntary_ack_within_aggregation(self, llc):
            dlc = [None, None, None, None]
            for i in range(len(dlc)):
                dlc[i] = llc.socket(nfc.llcp.DATA_LINK_CONNECTION)
                llc.setsockopt(dlc[i], nfc.llcp.SO_RCVBUF, 2)
                pdu = nfc.llcp.pdu.ConnectionComplete(32+i, 16+i, 248)
                threading.Timer(0.01, llc.collect).start()
                threading.Timer(0.02, llc.dispatch, (pdu,)).start()
                llc.connect(dlc[i], 16+i)

            llc.send(dlc[0], 230 * b'1', nfc.llcp.MSG_DONTWAIT)
            pdu = nfc.llcp.pdu.Information(33, 17, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[1]) == b'123'
            pdu = nfc.llcp.pdu.Information(34, 18, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[2]) == b'123'
            pdu = nfc.llcp.pdu.Information(35, 19, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[3]) == b'123'
            assert llc.collect() == nfc.llcp.pdu.AggregatedFrame(0, 0, [
                nfc.llcp.pdu.Information(16, 32, 0, 0, 230 * b'1'),
                nfc.llcp.pdu.ReceiveReady(17, 33, 1),
                nfc.llcp.pdu.ReceiveReady(18, 34, 1)
            ])
            assert llc.collect() == nfc.llcp.pdu.ReceiveReady(19, 35, 1)
Beispiel #3
0
 def test_send_with_connected_dlc_socket(self, llc, dlc):
     pdu = nfc.llcp.pdu.ConnectionComplete(32, 17)
     threading.Timer(0.01, llc.collect).start()
     threading.Timer(0.02, llc.dispatch, (pdu,)).start()
     llc.connect(dlc, 17)
     llc.send(dlc, b'123', nfc.llcp.MSG_DONTWAIT)
     pdu = llc.collect()
     assert isinstance(pdu, nfc.llcp.pdu.Information)
     assert pdu.dsap == 17 and pdu.ssap == 32 and pdu.data == b'123'
Beispiel #4
0
 def test_send_with_connected_dlc_socket(self, llc, dlc):
     pdu = nfc.llcp.pdu.ConnectionComplete(32, 17)
     threading.Timer(0.01, llc.collect).start()
     threading.Timer(0.02, llc.dispatch, (pdu,)).start()
     llc.connect(dlc, 17)
     llc.send(dlc, b'123', nfc.llcp.MSG_DONTWAIT)
     pdu = llc.collect()
     assert isinstance(pdu, nfc.llcp.pdu.Information)
     assert pdu.dsap == 17 and pdu.ssap == 32 and pdu.data == b'123'
Beispiel #5
0
 def test_send_with_unconnected_dlc_socket(self, llc, dlc):
     with pytest.raises(nfc.llcp.Error) as excinfo:
         llc.send(dlc, b'123', nfc.llcp.MSG_DONTWAIT)
     assert excinfo.value.errno == errno.ENOTCONN
Beispiel #6
0
 def test_send_with_connected_ldl_socket(self, llc, ldl):
     llc.connect(ldl, 16)
     assert llc.send(ldl, b'123', nfc.llcp.MSG_DONTWAIT) is True
     pdu = llc.collect()
     assert isinstance(pdu, nfc.llcp.pdu.UnnumberedInformation)
     assert pdu.dsap == 16 and pdu.ssap == 32 and pdu.data == b'123'
Beispiel #7
0
 def test_send_with_unconnected_ldl_socket(self, llc, ldl):
     with pytest.raises(nfc.llcp.Error) as excinfo:
         llc.send(ldl, b'123', nfc.llcp.MSG_DONTWAIT)
     assert excinfo.value.errno == errno.EDESTADDRREQ
Beispiel #8
0
 def test_send_with_unconnected_dlc_socket(self, llc, dlc):
     with pytest.raises(nfc.llcp.Error) as excinfo:
         llc.send(dlc, b'123', nfc.llcp.MSG_DONTWAIT)
     assert excinfo.value.errno == errno.ENOTCONN
Beispiel #9
0
 def test_send_with_connected_ldl_socket(self, llc, ldl):
     llc.connect(ldl, 16)
     assert llc.send(ldl, b'123', nfc.llcp.MSG_DONTWAIT) is True
     pdu = llc.collect()
     assert isinstance(pdu, nfc.llcp.pdu.UnnumberedInformation)
     assert pdu.dsap == 16 and pdu.ssap == 32 and pdu.data == b'123'
Beispiel #10
0
 def test_send_with_unconnected_ldl_socket(self, llc, ldl):
     with pytest.raises(nfc.llcp.Error) as excinfo:
         llc.send(ldl, b'123', nfc.llcp.MSG_DONTWAIT)
     assert excinfo.value.errno == errno.EDESTADDRREQ