Guest User

Untitled

a guest
Aug 8th, 2014
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. int hello(void)
  2. {
  3.   int result;
  4.  
  5.   if (udpmain->Connected())
  6.   {
  7.     sprintf(DataOut, "%s", "Are_you_KAU-2?\r\n");
  8.     udpmain->Send(DataOut, 0);
  9.  
  10.     int i = udpmain->ReceiveBuffer(rec, 300);
  11.     if(i==0)
  12.     {
  13.       sprintf(str, "%s", "Device not detected!\r\n");
  14.       result = error_no_answer;
  15.       kau2_disconnect();
  16.     }
  17.     else
  18.     {
  19.       BytesToRaw(rec, rec_char, 8);
  20.       if (strcmp(rec_char, "Yes_I_am") == 0)
  21.       {
  22.         result = error_success;
  23.       }
  24.       else
  25.       {
  26.         result = error_bad_answer;
  27.         kau2_disconnect();
  28.       }
  29.     }
  30.   }
  31.   else
  32.   {
  33.     result = error_socket;
  34.     kau2_disconnect();
  35.   }
  36.  
  37.   memset(DataOut, NULL, sizeof(str));
  38.   rec[0] = 0;
  39.   memset(rec_char, NULL, sizeof(rec_char));
  40.   return result;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment