MGC Arduino Server & Client

The Arduino Server and Client code is based on the Mini Grand Challenge Arduino Controller Communication protocol. This standard allows us to easily and quickly communicate with the Mini Grand Vehicle.

Arduino Server Code
The Arduino Server is the the code running on the physical Arduino Microcontroller. The reason why this is considered "server" code is that it runs in parallel and independently from the main code. This will be written in the Arduino programming language (Very similar to C/C++), being called from the core "setup" and "loop" functions. Communications will occur when a client connects and sends command packets, which should be processed appropriately. This is documented in Mini Grand Challenge Arduino Controller Communication. This communication will be over serial at the standard baud rate of 9600.

The source will be split into the main ArduinoServer.pde source file, communication function will be placed in Commands.c/h, and any hardware related functions will be placed in Hardware.c/h

ArduinoServer


 * Main entry point of the Arduino server application. Initializes the communication.
 * Main entry point of the Arduino server application. Initializes the communication.


 * Main application loop. Call's the command "GetMsg" and correctly parses them based on the communication protocol.
 * Main application loop. Call's the command "GetMsg" and correctly parses them based on the communication protocol.

Commands


 * Instruction set enumeration.
 * Instruction set enumeration.


 * Return set enumeration.
 * Return set enumeration.


 * Recieves and builds a message from the serial port, posting the instruction and value in the given pointers. True is returned on sucess, false otherwise.
 * Recieves and builds a message from the serial port, posting the instruction and value in the given pointers. True is returned on sucess, false otherwise.


 * Returns a confirmation message and value if the message is RET_VAL.
 * Returns a confirmation message and value if the message is RET_VAL.


 * Parse a given string into an ArduinoInstr.
 * Parse a given string into an ArduinoInstr.

Hardware


 * Initialize all hardware components.
 * Initialize all hardware components.


 * Release all hardware components.
 * Release all hardware components.


 * Return the range-finder by index.
 * Return the range-finder by index.


 * Set the angle of the wheels.
 * Set the angle of the wheels.


 * Return the compass bearing, make sure to not query too fast.
 * Return the compass bearing, make sure to not query too fast.


 * Set the speed of the vehicle.
 * Set the speed of the vehicle.


 * Return the real-world vehicle speed.
 * Return the real-world vehicle speed.


 * Wheel encoder interrupt event function.
 * Wheel encoder interrupt event function.

Arduino Client Code
As mentioned above, the Arduino client is a class that allows a user to send managed packets to the Arduino client and query data. It will be implemented as a C++ class.


 * ArduinoClient constructor. The DeviceName is the device name ASCII string, and BaudRate is the speed of communications, defaulted to 9600.
 * ArduinoClient constructor. The DeviceName is the device name ASCII string, and BaudRate is the speed of communications, defaulted to 9600.


 * Destructor and releases the device communication.
 * Destructor and releases the device communication.


 * Returns true if there is at any point a failure of communication.
 * Returns true if there is at any point a failure of communication.


 * Create a packet based on the given command as well as parameters and send it to the target device. A parameter may also be given. A negative values is returned on error, zero for no error, and a positive value for any return case for certain instructions.
 * Create a packet based on the given command as well as parameters and send it to the target device. A parameter may also be given. A negative values is returned on error, zero for no error, and a positive value for any return case for certain instructions.