Пример #1
0
def _socket_rx():
    global _socket
    while True:
        data, address = _socket.recvfrom(config.FRAME_MAX_LEN)
        if len(data) == 0:
            continue
        lagan.info(config.TAG, 'udp rx:%r len:%d', address, len(data))
        lagan.print_hex(config.TAG, lagan.LEVEL_DEBUG, bytearray(data))
        pipe_receive(dcom.addr_to_pipe(address[0], address[1]), data)
Пример #2
0
def case1():
    lagan.load()
    lagan.set_filter_level(lagan.LEVEL_DEBUG)
    lagan.enable_color(False)
    lagan.println('case1', lagan.LEVEL_OFF, 'TestPrintOut1:%d', 100)
    lagan.println('case1', lagan.LEVEL_DEBUG, 'TestPrintOut1:%d', 100)
    lagan.println('case1', lagan.LEVEL_INFO, 'TestPrintOut1:%d', 100)
    lagan.println('case1', lagan.LEVEL_WARN, 'TestPrintOut1:%d', 100)
    lagan.println('case1', lagan.LEVEL_ERROR, 'TestPrintOut1:%d', 100)

    s = bytearray()
    for i in range(100):
        s.append(i)
    lagan.print_hex('case1', lagan.LEVEL_INFO, s)
Пример #3
0
def _socket_rx():
    global _socket, _item
    while True:
        data, address = _socket.recvfrom(config.FRAME_MAX_LEN)
        if len(data) == 0:
            continue
        lagan.info(config.TAG, 'udp rx:%r len:%d', address, len(data))
        lagan.print_hex(config.TAG, lagan.LEVEL_DEBUG, bytearray(data))

        if _item.is_rx:
            lagan.warn(config.TAG, 'udp rx:%r len:%d.deal is too slow!!!',
                       address, len(data))
            continue
        _item.pipe = dcom.addr_to_pipe(address[0], address[1])
        _item.data = data
        _item.is_rx = True
Пример #4
0
def case2():
    lagan.load()
    s = bytearray()
    for i in range(100):
        s.append(i)
    lagan.print_hex('case2', lagan.LEVEL_ERROR, s)
Пример #5
0
def _socket_tx(pipe: int, data: bytearray):
    ip, port = dcom.pipe_to_addr(pipe)
    _socket.sendto(data, (ip, port))
    lagan.info(config.TAG, "udp send:ip:%s port:%d len:%d", ip, port,
               len(data))
    lagan.print_hex(config.TAG, lagan.LEVEL_DEBUG, data)