#Assert that message with Image Name and Image Size was received ret = udpClient.receiveUDPmsg(delay) print "[ImageSource] Mensagem recebida do MidiSource" , ret # ******************************************************** #Connect to RPI TCP server if(ret=="OK"): tcpClient = TCPClient(RPI_IP,TCP_PORT,BUFFER_SIZE) tcpClient.connectTCP() print '[ImageSource] TCP Client ready to send the image' #tcpClient.sendFileByNameAndClose(imgname) # ******************************************************** #Send Image tcpClient.sendDataBySize(img.read(), size) # ******************************************************** #Close TCP socket tcpClient.closeTCPclient() print '[ImageSource] TCPClient closed' #**************************MIDI PART****************************************** # ******************************************************** #Wait for UDP Packet Flag saying MIDI is ready to be sent ret = udpClient.receiveUDPmsg(delay) # ******************************************************** #Start TCP Server midi_data=ret.split(',') print '[ImageSource] Image Name: {0}, Image Size: {1}'.format(midi_data[0], midi_data[1]) # ******************************************************** #Accept RPI TCP connection tcpServer = TCPServer(MY_IP,TCP_PORT,BUFFER_SIZE,os.uname()[1]) tcpServer.bindSocket() udpClient.sendUDPmsg("OK", RPI_IP, UDP_PORT)
#Assert that message with Image Name and Image Size was received ret = udpClient.receiveUDPmsg(delay) print "[ImageSource] Mensagem recebida do MidiSource", ret # ******************************************************** #Connect to RPI TCP server if (ret == "OK"): tcpClient = TCPClient(RPI_IP, TCP_PORT, BUFFER_SIZE) tcpClient.connectTCP() print '[ImageSource] TCP Client ready to send the image' #tcpClient.sendFileByNameAndClose(imgname) # ******************************************************** #Send Image tcpClient.sendDataBySize(img.read(), size) # ******************************************************** #Close TCP socket tcpClient.closeTCPclient() print '[ImageSource] TCPClient closed' #**************************MIDI PART****************************************** # ******************************************************** #Wait for UDP Packet Flag saying MIDI is ready to be sent ret = udpClient.receiveUDPmsg(delay) # ******************************************************** #Start TCP Server midi_data = ret.split(',') print '[ImageSource] Image Name: {0}, Image Size: {1}'.format( midi_data[0], midi_data[1]) # ******************************************************** #Accept RPI TCP connection tcpServer = TCPServer(MY_IP, TCP_PORT, BUFFER_SIZE, os.uname()[1]) tcpServer.bindSocket()