Part One of my Project Course. Implementation of simple I/O and a custom defined protocol over UDP/IP.

Dependencies:   C12832 LM75B mbed EthernetInterface mbed-rtos

Revision:
2:6bfe732ba6bc
Parent:
1:b5c534165dfe
Child:
3:538e17979246
diff -r b5c534165dfe -r 6bfe732ba6bc master.cpp
--- a/master.cpp	Wed Mar 14 07:59:21 2018 +0000
+++ b/master.cpp	Mon Mar 19 11:32:54 2018 +0000
@@ -1,5 +1,4 @@
 #include "master.h"
-#include "command.h"
 #include "EthernetInterface.h"
 #include <string.h>
 #include <stdio.h>
@@ -59,9 +58,9 @@
             }
             case STATE_RECEIVING_FROM_PC:
             {
-                printf("Enter your command.\r\n");
+                sendMessageToPc("Enter your command.");
                 char temp1;
-
+                memset(&inputCommandArray[0], 0, sizeof(inputCommandArray));
                 char_counter_command = 0;
                 for(int i = 0; i <= MAX_PACKET_SIZE; i ++){
                     temp1 = pc.getc();
@@ -91,6 +90,7 @@
                     client_id[char_counter_id] = temp2;
                     char_counter_id++;
                 }
+                
                 client_ip[10] = client_id[0];
                 client_ip[11] = client_id[1];
                 client_ip[12] = client_id[2];
@@ -110,7 +110,6 @@
             case STATE_HANDLE_RESPONSE:
             {
                 memset(&in_buffer[0], 0, sizeof(in_buffer)); //buffer clear voor ontvangst
-                //start timer
                 int n = sock_master.receiveFrom(client, in_buffer, sizeof(in_buffer));
                 sock_master.close();
                 //stop timer, niet voltooid -> error state
@@ -121,7 +120,7 @@
             }
             case STATE_ERROR_STATE:
             {   
-                printf("Error: did not receive a response from the client in time");
+                sendMessageToPc("Error: did not receive a response from the client in time");
                 memset(&in_buffer[0], 0, sizeof(in_buffer)); //buffer clear
                 CurrentMasterState = STATE_RECEIVING_FROM_PC;
                 break;
@@ -133,7 +132,7 @@
         printf(message_to_pc);
         printf("\r\n");
     }
-   
+    
 }