38 recvBufSize = 0x1000000
41 def uppercase(input_array, total_size, fpga_ip, fpga_port, debug_level):
42 logging.basicConfig(level=debug_level)
43 bytesToSend = input_array.tostring()
45 UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
46 previous_buffer_size = UDPClientSocket.getsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF)
47 UDPClientSocket.setsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF, recvBufSize)
48 real_buffer_size = UDPClientSocket.getsockopt(socket.SOL_SOCKET,socket.SO_RCVBUF)
49 if(real_buffer_size/2 != recvBufSize):
50 logging.warning(
"set SO_RCVBUF failed! got only: " +
str(real_buffer_size/2) +
"; trying to continue...")
52 serverAddressPort = (fpga_ip, fpga_port)
55 logging.debug(
"Sending bytes: " +
str(cnt*BUFF_SIZE) +
" : " +
str((cnt+1)*BUFF_SIZE-1))
56 UDPClientSocket.sendto(bytesToSend[cnt*BUFF_SIZE:(cnt+1)*BUFF_SIZE], serverAddressPort)
57 if ((cnt+1)*BUFF_SIZE >= total_size):
58 logging.debug(
"INFO: Reached size to sent")
63 output_array = np.zeros((total_size,), dtype=input_array.dtype)
65 logging.debug(
"Receiving bytes: " +
str(cnt*BUFF_SIZE) +
" : " +
str((cnt+1)*BUFF_SIZE-1))
66 msgFromServer = UDPClientSocket.recvfrom(BUFF_SIZE)
67 y = np.frombuffer(msgFromServer[0], dtype=input_array.dtype)
68 logging.debug(output_array[cnt*BUFF_SIZE:(cnt+1)*BUFF_SIZE-1].size)
69 output_array[cnt*BUFF_SIZE:(cnt+1)*BUFF_SIZE] = y
70 if ((cnt+1)*BUFF_SIZE >= total_size):
71 logging.debug(
"Reached size to receive")
77 if __name__ ==
'__main__':
def uppercase(input_array, total_size, fpga_ip, fpga_port, debug_level)