Bert Gereels / Mbed 2 deprecated ProjectOne

Dependencies:   C12832 LM75B mbed EthernetInterface mbed-rtos

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers master.h Source File

master.h

00001 #pragma once
00002 
00003 #include "mbed.h"
00004 
00005 #define MAX_COMMAND_LENGTH 20
00006 
00007 namespace ProjectOne{
00008  
00009     class Master{
00010         public:
00011             /*
00012             * Constructor for Master class.
00013             *
00014             @param The id for the master that is selected on boot.
00015             @return Nothing.
00016             */
00017             Master(int master_id);
00018             
00019             /*
00020             * Method that sends characters to serial connection on pc.
00021             *
00022             @param Characters that need to be displayed.
00023             @return Nothing.
00024             */
00025             void sendMessageToPc(char *thingsToDisplay);
00026             
00027             /*
00028             * Method that contains the master state-machine.
00029             * Waits for input from the user entered via a serial connection.
00030             * When command is entered, prompts user for slave id to send to.
00031             * Sends UDP packet to slave.
00032             * Waits for the response/acknowledgement from the slave.
00033             * Displays acknowledgement.
00034             *
00035             @param Char array containing the characters to display.
00036             @return Nothing.
00037             */
00038             void handlePcData(void);
00039             
00040         private:
00041             enum masterStates{
00042                 STATE_INIT,
00043                 STATE_RECEIVING_FROM_PC,
00044                 STATE_HANDLE_ID,
00045                 STATE_SEND_UDP_PACKET,
00046                 STATE_HANDLE_RESPONSE,
00047                 STATE_ERROR_STATE
00048             };
00049             
00050             masterStates CurrentMasterState;
00051 
00052             char inputCommandArray[512];
00053             char client_id[4];
00054             int char_counter_command, char_counter_id;
00055             
00056             int masterId;
00057             
00058             const static char *MASK;
00059             const static char *GATEWAY;
00060             
00061             Timer timer;
00062          
00063     };
00064  
00065 };