int main(int argc, char *argv[]) {
  if ((argc < 3) || (argc > 4)) {   // Test for correct number of arguments
    cerr << "Usage: " << argv[0] 
         << " <Destination Address> <Destination Port> <Send String>\n";
    exit(1);
  }

  string destAddress = argv[1];             // First arg:  destination address
  unsigned short destPort = atoi(argv[2]);  // Second arg: destination port
  char* sendString = argv[3];               // Third arg:  string to broadcast

  try {
    UDPSocket sock;
  
    // Repeatedly send the string (not including \0) to the server
    for (;;) {
      sock.sendTo(sendString, strlen(sendString), destAddress, destPort);
      sleep(3);
    }
  } catch (SocketException &e) {
    cerr << e.what() << endl;
    exit(1);
  }
  
  return 0;
}
Exemple #2
0
void
WatchDog::continuousStatusReport( std::string theStateMsg) {
    if (_myContinuousStateChangeIP != "" && _myContinuousStateChangePort != -1) {
        try {
            AC_DEBUG << "send State: " << theStateMsg;
            UDPSocket * myUDPClient = 0;
            Unsigned32 inHostAddress = getHostAddress(_myContinuousStateChangeIP.c_str());
            // try to find a free client port between _myContinuousStateChangePort+1 and MAX_PORT
            for (unsigned int clientPort = _myContinuousStateChangePort+1; clientPort <= MAX_PORT; clientPort++)
            {
                try {
                    myUDPClient = new UDPSocket(INADDR_ANY, clientPort);
                    break;
                }
                catch (SocketException & ) {
                    myUDPClient = 0;
                }
            }
            if (myUDPClient) {
                myUDPClient->sendTo(inHostAddress, _myContinuousStateChangePort, theStateMsg.c_str(), theStateMsg.size());
                delete myUDPClient;
            }
        }
        catch (Exception & ) {
            _myLogger.logToFile(std::string("Sorry, cannot establish socket connection to ip: '") + _myContinuousStateChangeIP + "'");            
        }
    }
}
int main(int argc, char *argv[]) {
  if ((argc < 4) || (argc > 5)) {   // Test for correct number of arguments
    cerr << "Usage: " << argv[0] 
         << " <Destination Address> <Destination Port> <Send String> [<TTL>]\n";
    exit(1);
  }

  string servAddress = argv[1];         // First arg: multicast address
  unsigned short port = atoi(argv[2]);  // Second arg: port
  char* sendString = argv[3];           // Third arg: string to echo

  unsigned char multicastTTL = 1;       // Default TTL
  if (argc == 5) {
    multicastTTL = atoi(argv[4]);       // Command-line TTL
  }

  try {
    UDPSocket sock;

    sock.setMulticastTTL(multicastTTL);

    // Repeatedly send the string to the server
    for (;;) {
      sock.sendTo(sendString, strlen(sendString), servAddress, port);
      sleep(3);
    }
  } catch (SocketException &e) {
    cerr << e.what() << endl;
    exit(1);
  }

  return 0;
}
Exemple #4
0
int main (void) {
    MBED_HOSTTEST_TIMEOUT(20);
    MBED_HOSTTEST_SELECT(udpecho_server_auto);
    MBED_HOSTTEST_DESCRIPTION(UDP echo server);
    MBED_HOSTTEST_START("NET_5");

    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("MBED: Server IP Address is %s:%d\r\n", eth.getIPAddress(), ECHO_SERVER_PORT);

    UDPSocket server;
    server.bind(ECHO_SERVER_PORT);

    Endpoint client;
    char buffer[BUFFER_SIZE] = {0};
    printf("MBED: Waiting for packet...\r\n");
    while (true) {
        int n = server.receiveFrom(client, buffer, sizeof(buffer));
        if (n > 0) {
            //printf("Received packet from: %s\n", client.get_address());
            const int buffer_string_end_index = n >= BUFFER_SIZE ? BUFFER_SIZE-1 : n;
            buffer[buffer_string_end_index] = '\0';
            //printf("Server received: %s\n", buffer);
            server.sendTo(client, buffer, n);
        }
    }
}
Exemple #5
0
void udp_client_task(void const *argument)
{
    while (host_port == 0) {
        // Waiting for HOST port notification
    }

    DigitalOut indicator(LED2);
    UDPSocket socket;
    socket.init();

    Endpoint echo_server;
    echo_server.set_address(host_address, host_port);
    //printf("[udp_client_task] Start: %s:%d\r\n", host_address, host_port);

    while (1) {
        std::string datagram;
        bool sent_datagram = false;
        cli_serv_mutex.lock(); // LOCK
        if (datagram_queue.size() > 0) {
            // POP from datagram queue
            datagram = datagram_queue.back();
            datagram_queue.pop_back();
            sent_datagram = true;
        }
        cli_serv_mutex.unlock(); // LOCK
        if (sent_datagram) {
            //printf("[udp_client_task] Forwarded datagram: %s\r\n", datagram.c_str());
            socket.sendTo(echo_server, (char *)datagram.c_str(), datagram.length());
            forwarded_packets++;
            indicator = !indicator;
        }
    }
}
Exemple #6
0
/* ===  FUNCTION  ==============================================================
 *         Name:  sendMsg
 *  Description:  This function sends the given msg to the give port
 * =============================================================================
 */
void sendMsg(char *outMsg, int outMsgSize, unsigned short int destPort)
{
  try {
    static UDPSocket sendSocket;
    sendSocket.sendTo(outMsg, outMsgSize, COM_IP_ADDR, destPort);
  } catch (SocketException &e) {
    cout<<"db: Cannot send msg"<<endl;
  }
  return;
}   /* -----  end of function sendMsg  ----- */
Exemple #7
0
void send_data(float* prob)
{
    std::ostringstream ss;
    for (int i=0; i<windowSize*windowSize; i++)
    {
//		printf("%f",prob[i]);
    }
//	std:string s = s(ss.str());
std:
    string s = convert(prob,windowSize*windowSize);

    char nameee[50];
    sprintf(nameee, "%d ", windowSize);
    s = nameee+s;
    //printf(s.c_str());//s.c_str());

    sock.sendTo(s.c_str(), strlen(s.c_str()), to_ip, to_port);
}
Exemple #8
0
int main() {
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    
    UDPSocket sock;
    sock.init();
    
    Endpoint multicast_group;
    multicast_group.set_address(MCAST_GRP, MCAST_PORT);
    
    char out_buffer[] = "very important data";
    while (true) {
        printf("Multicast to group: %s\n", MCAST_GRP);
        sock.sendTo(multicast_group, out_buffer, sizeof(out_buffer));
        Thread::wait(1000);
    }
}
Exemple #9
0
int main (void) {
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("IP Address is %s\n", eth.getIPAddress());
    
    UDPSocket server;
    server.bind(ECHO_SERVER_PORT);
    
    Endpoint client;
    char buffer[256];
    while (true) {
        printf("\nWait for packet...\n");
        int n = server.receiveFrom(client, buffer, sizeof(buffer));
        
        printf("Received packet from: %s\n", client.get_address());
        server.sendTo(client, buffer, n);
    }
}
Exemple #10
0
void UDPClient::service()
{
  char sendBuffer[ECHOMAX] = {};				// Buffer for send string (send)
  this->sendString.copy(sendBuffer, sendString.length(), 0);
  int echoStringLen;				    // Length of string to echo
  echoStringLen = strlen(sendBuffer);

  if (echoStringLen > ECHOMAX) {    // Check input length
    cerr << "Echo string too long" << endl;
    exit(1);
  }
  //unsigned short echoServPort = Socket::resolveService("echo", "udp");

  try {
    UDPSocket sock;

    // Send the string to the server
    sock.sendTo(sendBuffer, echoStringLen, servAddress, echoServPort);
  
    // Receive a response
    respStringLen = sock.recv(echoBuffer, ECHOMAX); // Length of received response

	echoBuffer[respStringLen] = '\0';             // Terminate the string!
    //cout << "Received: " << echoBuffer << endl;   // Print the echoed arg
  
	if(respStringLen > 0)
	{
		response = echoBuffer;
		parsing();
		//string temp; 
		//std::stringstream os(response);
		//os >> temp;
	}

    // Destructor closes the socket
	//sock.disconnect();
	//sock.cleanUp();

  } catch (SocketException &e) {
    cerr << e.what() << endl;
    exit(1);
  }
}
Exemple #11
0
int main(int argc, char *argv[]) {
  if ((argc < 3) || (argc > 4)) {   // Test for correct number of arguments
    cerr << "Usage: " << argv[0] 
         << " <Server> <Echo String> [<Server Port>]\n";
    exit(1);
  }

  string servAddress = argv[1];             // First arg: server address
  char* echoString = argv[2];               // Second arg: string to echo
  int echoStringLen = strlen(echoString);   // Length of string to echo
  if (echoStringLen > ECHOMAX) {    // Check input length
    cerr << "Echo string too long" << endl;
    exit(1);
  }
  unsigned short echoServPort = Socket::resolveService(
    (argc == 4) ? argv[3] : "echo", "udp");

  try {
    UDPSocket sock;
  
    // Send the string to the server
    sock.sendTo(echoString, echoStringLen, servAddress, echoServPort);
  
    // Receive a response
    char echoBuffer[ECHOMAX + 1];       // Buffer for echoed string + \0
    int respStringLen;                  // Length of received response
    if ((respStringLen = sock.recv(echoBuffer, ECHOMAX)) != echoStringLen) {
      cerr << "Unable to receive" << endl;
      exit(1);
    }
  
    echoBuffer[respStringLen] = '\0';             // Terminate the string!
    cout << "Received: " << echoBuffer << endl;   // Print the echoed arg

    // Destructor closes the socket

  } catch (SocketException &e) {
    cerr << e.what() << endl;
    exit(1);
  }
  
  return 0;
}
Exemple #12
0
int
main (int argc, char *argv[])
{

  if (argc != 2)
    { // Test for correct number of parameters
      cerr << "Usage: " << argv[0] << " <Server Port>" << endl;
      exit (1);
    }

  unsigned short echoServPort = atoi (argv[1]); // First arg:  local port

  try
    {
      UDPSocket sock (echoServPort);

      char echoBuffer[ECHOMAX];  // Buffer for echo string
      int recvMsgSize;           // Size of received message
      string sourceAddress;      // Address of datagram source
      unsigned short sourcePort; // Port of datagram source
      for (;;)
        { // Run forever
          // Block until receive message from a client
          recvMsgSize
              = sock.recvFrom (echoBuffer, ECHOMAX, sourceAddress, sourcePort);

          cout << "Received packet from " << sourceAddress << ":" << sourcePort
               << endl;

          sock.sendTo (echoBuffer, recvMsgSize, sourceAddress, sourcePort);
        }
    }
  catch (SocketException &e)
    {
      cerr << e.what () << endl;
      exit (1);
    }
  // NOT REACHED

  return 0;
}
Exemple #13
0
int UDPSocketTest::run_test()
{
	cout << "UDP Socket test" << endl;

	UDPSocket* sSocket = new UDPSocket(3346);
	UDPSocket* cSocket = new UDPSocket();
	string message = "Test 1234567890";
	printf("sending\n");
	cSocket->sendTo(message,"127.0.0.1", 3346);
	char buffer[100];
	memset((void*)buffer,0,100);
	int rc = sSocket->recv(buffer, 100);
	cout<<"send msg:"<<message<<endl;
	cout<<"recv msg:"<<buffer<<endl;
	if (rc != (int)message.length()){
		perror("FAIL1: receive different message length");
	}
	if (message != buffer){
		perror("FAIL2: receive different message");
	}
	message = "Test Reply 129012901290";
	sSocket->reply(message);
	memset((void*)buffer,0,100);
	rc = cSocket->recv(buffer, 100);
	cout<<"send msg:"<<message<<endl;
	cout<<"recv msg:"<<buffer<<endl;
	if (rc != (int)message.length()){
		perror("FAIL1: receive different message length");
	}
	if (message != buffer){
		perror("FAIL2: receive different message");
	}
	sSocket->close();
	cSocket->close();
	delete sSocket;
	delete cSocket;
	printf("Bye bye..\n");
	return 0;
}
Exemple #14
0
int main() {
    bool result = false;
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("UDP client IP Address is %s\n", eth.getIPAddress());

    UDPSocket sock;
    sock.init();

    Endpoint nist;
    nist.set_address(HTTP_SERVER_NAME, HTTP_SERVER_PORT);

    char out_buffer[] = "plop"; // Does not matter
    sock.sendTo(nist, out_buffer, sizeof(out_buffer));

    union {
        char in_buffer_tab[4];
        unsigned int in_buffer_uint;
    };

    const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab));
    if (n > 0) {
        result = true;
        const unsigned int timeRes = ntohl(in_buffer_uint);
        const float years = timeRes / 60.0 / 60.0 / 24.0 / 365;
        printf("UDP: Received %d bytes from server %s on port %d\r\n", n, nist.get_address(), nist.get_port());
        printf("UDP: %u seconds since 01/01/1900 00:00 GMT ... %s\r\n", timeRes, timeRes > 0 ? "[OK]" : "[FAIL]");
        printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]");

        if (years < YEARS_TO_PASS) {
            result = false;
        }
    }
    sock.close();
    eth.disconnect();
    notify_completion(result);
    return 0;
}
void UDPMulticastSender::send()
{
	try {
		UDPSocket sock;

		sock.setMulticastTTL(multicastTTL);
		//sock.setBroadcast();

		Sleep(7000); //Wait the Simulation Start

		// Repeatedly send the string to the server
		for (;;) {
 			buildSendMessage();

			sock.sendTo(sendBuffer, bufLen, servAddress, port);
			Sleep(1000./60.); //camera 60 fps
		}
	} catch (SocketException &e) {
		cerr << e.what() << endl;
		exit(1);
	}
}
Exemple #16
0
int main (void) {
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("Server IP Address is %s:%d\n", eth.getIPAddress(), ECHO_SERVER_PORT);
    
    UDPSocket server;
    server.bind(ECHO_SERVER_PORT);
    
    Endpoint client;
    char buffer[BUFFER_SIZE] = {0};
    while (true) {
        printf("Wait for packet...\n");
        int n = server.receiveFrom(client, buffer, sizeof(buffer));
        if (n > 0) {
            printf("Received packet from: %s\n", client.get_address());
            const int buffer_string_end_index = n >= BUFFER_SIZE ? BUFFER_SIZE-1 : n;
            buffer[buffer_string_end_index] = '\0';
            printf("Server received: %s\n", buffer);
            server.sendTo(client, buffer, n);
        }
    }
}
static int
send_to_peer(struct dtls_context_t *ctx,
        session_t *session, uint8 *data, size_t len) {
  printf("sendtopeer\n");

    // find lwm2m connection
    connection_t * connP = connList;
    while(connP != NULL) {
        printf("conn\n");
        if (strcmp(connP->host, session->addr) == 0 && connP->port == session->port)
        {
            printf("found connection\n");
            int bytes = udp.sendTo(connP->ep, (char*)data, len);

            if (-1 == bytes)
            {
                printf("error seding udp datagram\n");
            }
            return bytes;
        }
    }
    return -1;
}
//Na 30 seconden timed the socket out en zal er een socketTimeoutExeption worden aangeroepen.
//Als je dit wilt aanpassen moet je dat veranderen in de prackticalsocket.cpp in de functie recvFRom
int main()
{
    UDPSocket sock;
    //Verander IP
    SocketAddress localadr("172.16.120.134", 8888, SocketAddress::UDP_SOCKET);
    sock.bind(localadr);
    SocketAddress remoteadr;
    cout << "UDP Server is gestart:" << endl;

    int32_t temp[5]= {1,2,3,4,5};
    //Dit bericht wordt verstuurd
    mavlink_message_t msg = encodeLidarMessage(temp, COMMAND_DESTINATION::COMMAND_DESTINATION_ENUM_END, LIDAR_COMMAND_FUNCTIONS::LIDAR_INIT);

    while(true){
            try{
				sock.recvFrom(&msg, sizeof(mavlink_message_t), remoteadr);

				cout << "recieved: " << decodeLidarMessage(msg).Payload[0] << endl;

				//Opnieuw een bericht samen stellen
				for(int i=0; i< 6; i++){
					temp[i] = decodeLidarMessage(msg).Payload[i] + 1;
				}

				msg = encodeLidarMessage( temp, COMMAND_DESTINATION::COMMAND_DESTINATION_ENUM_END, LIDAR_COMMAND_FUNCTIONS::LIDAR_INIT);

				sock.sendTo(&msg, sizeof(mavlink_message_t), remoteadr);

				cout << "sending: " << decodeLidarMessage(msg).Payload[0] << endl;
				cout << "from: " << remoteadr.getAddress() << ":" << remoteadr.getPort() << endl;

				sleep(1);
            }catch(SocketTimedOutException e){
            	continue;
            }
    }
}
int main(int argc, char **argv)
{
	UDPSocket sock;
	SocketAddress localadr("145.89.98.137", 2222, SocketAddress::UDP_SOCKET);
	sock.bind(localadr);
	SocketAddress remoteadr;
	sock.setTimeOut(2);

	int count = 0;
	while(true){
		try{
			cout << "waiting" << endl;

			sock.recvFrom(&count, sizeof(int), remoteadr);

			cout << "recieved: " << count << endl;
			cout << "from: " << remoteadr.getAddress() << ":" << remoteadr.getPort() << endl;

			count++;
			sock.sendTo(&count, sizeof(int), remoteadr );

		}catch(SocketTimedOutException e){continue;}
	}
}
/* send a buffer to a session*/
static uint8_t prv_buffer_send(void * sessionH,
                               uint8_t * buffer,
                               size_t length,
                               void * userdata)
{
    printf("sending\n");
    connection_t * connP = (connection_t*) sessionH;

    if (connP == NULL)
    {
        printf("#> failed sending %lu bytes, missing connection\r\n", length);
        return COAP_500_INTERNAL_SERVER_ERROR;
    }

    printf("sending to %s\n",connP->ep.get_address());

    if (connP->dtlsSession == NULL)
	{
		printf("send NO_SEC datagram\n");
		if (-1 == udp.sendTo(connP->ep, (char*)buffer, length))
		{
			printf("send error\n");
			return COAP_500_INTERNAL_SERVER_ERROR;
		}
	} else {
		printf("send thru dtls\n");
		
		int res = dtls_write(dtls_context, connP->dtlsSession, (uint8 *)buffer, length);
		if (res != length)
		{
			printf("send dtls error: %d\n", res);
			return COAP_500_INTERNAL_SERVER_ERROR;
		}
	}
    return COAP_NO_ERROR;
}
Exemple #21
0
void TLD::processFrame(const cv::Mat& img1,const cv::Mat& img2,vector<Point2f>& points1,vector<Point2f>& points2,BoundingBox& bbnext,bool& lastboxfound, bool tl, FILE* bb_file){
	vector<BoundingBox> cbb;
	vector<float> cconf;
	int confident_detections=0;
	int didx; //detection index
	///Track
	if(lastboxfound && tl){
		track(img1,img2,points1,points2);
	}
	else{
		tracked = false;
	}
	///Detect
	detect(img2);
	///Integration
	if (tracked){
		bbnext=tbb;
		lastconf=tconf;
		lastvalid=tvalid;
		//printf("Tracked\n");
		if(detected){                                               //   if Detected
			clusterConf(dbb,dconf,cbb,cconf);                       //   cluster detections
			//printf("Found %d clusters\n",(int)cbb.size());
			for (int i=0;i<cbb.size();i++){
				if (bbOverlap(tbb,cbb[i])<0.5 && cconf[i]>tconf){  //  Get index of a clusters that is far from tracker and are more confident than the tracker
					confident_detections++;
					didx=i; //detection index
				}
			}
			if (confident_detections==1){                                //if there is ONE such a cluster, re-initialize the tracker
				//printf("Found a better match..reinitializing tracking\n");
				bbnext=cbb[didx];
				lastconf=cconf[didx];
				lastvalid=false;
			}
			else {
				//printf("%d confident cluster was found\n",confident_detections);
				int cx=0,cy=0,cw=0,ch=0;
				int close_detections=0;
				for (int i=0;i<dbb.size();i++){
					if(bbOverlap(tbb,dbb[i])>0.7){                     // Get mean of close detections
						cx += dbb[i].x;
						cy +=dbb[i].y;
						cw += dbb[i].width;
						ch += dbb[i].height;
						close_detections++;
						//printf("weighted detection: %d %d %d %d\n",dbb[i].x,dbb[i].y,dbb[i].width,dbb[i].height);
					}
				}
				if (close_detections>0){
					bbnext.x = cvRound((float)(10*tbb.x+cx)/(float)(10+close_detections));   // weighted average trackers trajectory with the close detections
					bbnext.y = cvRound((float)(10*tbb.y+cy)/(float)(10+close_detections));
					bbnext.width = cvRound((float)(10*tbb.width+cw)/(float)(10+close_detections));
					bbnext.height =  cvRound((float)(10*tbb.height+ch)/(float)(10+close_detections));









					printf("Tracker bb: %d %d %d %d\n",tbb.x,tbb.y,tbb.width,tbb.height);
					printf("Average bb: %d %d %d %d\n",bbnext.x,bbnext.y,bbnext.width,bbnext.height);
					printf("GOT HERE! \n");
					//+ itoa(tbb.y) + itoa(tbb.width) + itoa(tbb.height)
					char tempString [50];
					char del = '_';
					sprintf(tempString,"%d%c%d%c%d%c%d", tbb.x,del,tbb.y,del,tbb.width,del,tbb.height);
					char* sendString = &tempString[0];
					sock.sendTo(sendString, strlen(sendString), destAddress, destPort);
					printf("GOT HERE BELOW! \n");
					//printf("Weighting %d close detection(s) with tracker..\n",close_detections);
				}
				else{
					//printf("%d close detections were found\n",close_detections);

				}
			}
		}
	}
	else{                                       //   If NOT tracking
		//printf("Not tracking..\n");
		lastboxfound = false;
		lastvalid = false;
		if(detected){                           //  and detector is defined
			clusterConf(dbb,dconf,cbb,cconf);   //  cluster detections
			//printf("Found %d clusters\n",(int)cbb.size());
			if (cconf.size()==1){
				bbnext=cbb[0];
				lastconf=cconf[0];
				//printf("Confident detection..reinitializing tracker\n");
				lastboxfound = true;
			}
		}
	}
	lastbox=bbnext;
	if (lastboxfound){}
	//fprintf(bb_file,"%d,%d,%d,%d,%f\n",lastbox.x,lastbox.y,lastbox.br().x,lastbox.br().y,lastconf);
	else{}
	//fprintf(bb_file,"NaN,NaN,NaN,NaN,NaN\n");

	if (lastvalid && tl)
		learn(img2);
}
void main(void)
{
    //***************** BEGINNING OF ETHERNET SETUP [DONT EDIT] *****************//
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("IP Address is %s\n", eth.getIPAddress());

    UDPSocket server;
    server.bind(ECHO_SERVER_PORT);

    Endpoint client;
    char buffer[256];

    //***************** END OF ETHERNET SETUP **********************************//

    //***************** BEGINNING OF WIRELESS SETUP [DONT EDIT] *****************//

    uint8_t channel = 6;
    //Set the Channel. 0 is default, 15 is max
    mrf.SetChannel(channel);
    //Start the timer
    timer.start();

    //***************** END OF WIRELESS SETUP **********************************//
    raiseAllPins();
    dropAllPins();


    speedChecker.attach(&speedLogic,0.005); //sets ticker for interrupts
    dcOUT=0; // turns DC motor off initially

    int cycles = 0;
    int flush = 0;
    int startChar =0;
    while(1) {
        dcPWM.write(dutyCycle);
        cycles = cycles-1;

        if(needsInput==true) {
            //What MBED is receiving from client?
            if(flush) {
                int lengthBuffer = strlen(buffer);
                for(int i = 0; i <lengthBuffer; i++) {
                    buffer[i]='\0';
                }
            }
            printf("\nWait for packet...\n\r");
            lightShow.drawChar('@'); //this should draw the character on the screen
            int n = server.receiveFrom(client, buffer, sizeof(buffer));
            printf("\nReceived packet...\n\r");
            printf("\nReceived integer n...%i\n\r",n);
            buffer[n]='\0';
            printf("\nyour word is: %s\n\r",buffer);
            server.sendTo(client, buffer, n); //echo protocol
            needsInput=false;
            cycles=n;
            /*revive code*/
            sendDelay = slowSpeed; //pins
            dutyCycle = slowMotor; //motor
            dcOUT = 1; //turn on motor
            off=false;
            slow = true;
            startChar=0;

        }
        if(cycles<=0) {
            needsInput= true;
            slow = false;
            off=true;
            dcOUT = 0; //turn motor off
            sendDelay = slowSpeed; //pins
            dutyCycle = slowMotor; //for whenever it turns on after you turned it off using REDUCE
        }

        if(!off) {
            char character = getNextCharacter(startChar, buffer);
            startChar=1;
            printf("\nchar: %c\n\r",character);
            int pinBinary = braille.matchCharacter(character);

            if(braille.isNumber(character)) {
                handleNumberCase(character);
            }
            led1=1;
            lightShow.drawChar(character); //this should draw the character on the screen
            led1=0;
            wait_ms(sendDelay);

            sendNumber(pinBinary);
            printf("Pinbinary: %i\n\r",pinBinary);

            //***** ACKNOWLEDGE CODE ******//

            int recLength = rf_receive(rxbuffer,128);
            while(recLength<=0) {
                led2=1;
                recLength = rf_receive(rxbuffer,128);
            }
            led2=0;
            //***** END ACKNOWLEDGE CODE ******//

        }//end if motor stopped code
        dropAllPins();
    }//end while loop
}//end all code