Beispiel #1
0
def main():
    serial_list = b''
    serial_count = 0
    serial_total = 153607
    serial_fifo = fifo.BytesFIFO(640 * 480 * 2)
    try:
        sock = socket.create_connection(('192.168.1.3', 23), 10)
        print('Created connection to 192.168.1.3')
        print('Recieving data...')
        while True:
            data = sock.recv(4096)
            if data:
                serial_count += len(data)
                serial_fifo.write(data)
            if serial_count == serial_total:
                print('Recieved whole image')
                display_image(serial_fifo.read(len(serial_fifo)))
                serial_list = b''
                serial_count = 0
                print('reset serial count and list')
    except Exception as e:
        print(serial_count)
        print(e)
        print('Connection failed/EVERYTHING IS ON FIRE')
        data = self.request[0]
        socket = self.request[1]
        #current_thread = threading.current_thread()
        #print("{}: client: {}, wrote: {}".format(current_thread.name, self.client_address, data))
        #socket.sendto(data.upper(), self.client_address)
        buffer.write(data)


class ThreadedUDPServer(socketserver.ThreadingMixIn, socketserver.UDPServer):
    pass


if __name__ == "__main__":
    host = "0.0.0.0"
    port = 1234
    buffer = fifo.BytesFIFO(1024)

    server = socketserver.ThreadingUDPServer((host, port),
                                             ThreadedUDPRequestHandler)
    server_thread = threading.Thread(target=server.serve_forever)
    server_thread.daemon = True

    status = 0

    try:
        server_thread.start()
        print("Server started at {} port {}".format(host, port))
        while True:
            if not (buffer.empty()):
                print(buffer.read(1))
Beispiel #3
0
 def test_capacity(self):
     self.assertEqual(10, self.f.capacity())
     self.assertEqual(5, fifo.BytesFIFO(5).capacity())
Beispiel #4
0
# Serial port
ser = serial.Serial()

# Serial Rx data
q_list = b''

# Serial command byte count and sizes
serial_count = 0
serial_total = 7
serial_header_size = 3
serial_msg_size = 0
serial_data_size = 0
serial_list = b''
serial_timeout = 2.0
serial_start_time = 0
serial_fifo = fifo.BytesFIFO(640 * 480 * 2)
serial_data_flag = 0

# Serial flag to block on transmit
serial_rx = True

# User Input
q_input = queue.Queue()

# st-util process
p = None

# gdb process
d = None

# wifi socket
Beispiel #5
0
 def setUp(self):
     self.f = fifo.BytesFIFO(10)