Exemple #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)
Exemple #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)
Exemple #3
0
 def test_recv(self, llc, dlc):
     llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 2)
     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)
     pdu = nfc.llcp.pdu.Information(32, 17, 0, 0, b'123')
     threading.Timer(0.01, llc.dispatch, (pdu,)).start()
     assert llc.recv(dlc) == b'123'
     assert llc.collect() == nfc.llcp.pdu.ReceiveReady(17, 32, 1)
Exemple #4
0
 def test_recv(self, llc, dlc):
     llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 2)
     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)
     pdu = nfc.llcp.pdu.Information(32, 17, 0, 0, b'123')
     threading.Timer(0.01, llc.dispatch, (pdu,)).start()
     assert llc.recv(dlc) == b'123'
     assert llc.collect() == nfc.llcp.pdu.ReceiveReady(17, 32, 1)
Exemple #5
0
        def test_collect_voluntary_ack_before_aggregation(self, llc):
            dlc = [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)
                threading.Timer(0.01, llc.collect).start()
                threading.Timer(0.02, llc.dispatch, (pdu,)).start()
                llc.connect(dlc[i], 16+i)

            pdu = nfc.llcp.pdu.Information(32, 16, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[0]) == b'123'
            assert llc.collect() == nfc.llcp.pdu.ReceiveReady(16, 32, 1)
Exemple #6
0
        def test_collect_voluntary_ack_before_aggregation(self, llc):
            dlc = [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)
                threading.Timer(0.01, llc.collect).start()
                threading.Timer(0.02, llc.dispatch, (pdu,)).start()
                llc.connect(dlc[i], 16+i)

            pdu = nfc.llcp.pdu.Information(32, 16, 0, 0, b'123')
            threading.Timer(0.01, llc.dispatch, (pdu,)).start()
            assert llc.recv(dlc[0]) == b'123'
            assert llc.collect() == nfc.llcp.pdu.ReceiveReady(16, 32, 1)
Exemple #7
0
 def test_setsockopt(self, llc, dlc):
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVMIU, 128) == 128
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVMIU, 248) == 248
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVMIU, 249) == 248
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 10) == 10
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 15) == 15
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 16) == 15
     with pytest.raises(nfc.llcp.Error) as excinfo:
         llc.setsockopt(object(), nfc.llcp.SO_RCVMIU, 128)
     assert excinfo.value.errno == errno.ENOTSOCK
Exemple #8
0
 def test_setsockopt(self, llc, dlc):
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVMIU, 128) == 128
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVMIU, 248) == 248
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVMIU, 249) == 248
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 10) == 10
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 15) == 15
     assert llc.setsockopt(dlc, nfc.llcp.SO_RCVBUF, 16) == 15
     with pytest.raises(nfc.llcp.Error) as excinfo:
         llc.setsockopt(object(), nfc.llcp.SO_RCVMIU, 128)
     assert excinfo.value.errno == errno.ENOTSOCK