Psi Swarm robot library version 0.9
Fork of PsiSwarmV9 by
Diff: serial.h
- Revision:
- 11:312663037b8c
- Parent:
- 9:dde9e21030eb
- Child:
- 16:50686c07ad07
diff -r e58323951c08 -r 312663037b8c serial.h --- a/serial.h Sun Oct 16 16:00:20 2016 +0000 +++ b/serial.h Sun Oct 16 21:06:15 2016 +0000 @@ -23,19 +23,42 @@ #ifndef SERIAL_H #define SERIAL_H - -void handle_user_serial_message(char * message, char length, char interface); +/** + * SerialControl class + * Functions to handle command and user messages sent over the PC or BT serial interfaces. Most of the functions within this class + * are not intended to be called by user applications; once the setup_serial_interfaces() function has been called the enabled + * serial ports are attached to listeners which handle any received messages. A predefined message structure for commands has been + * created which allows most functions on the robot to be externally called, either using a PC-robot or Bluetooth connection. + * + * For user functions, the main.cpp file should include a void handle_user_serial_message(char * message, char length, char interface) + * function to handle user-defined messages. + * +*/ +class SerialControl +{ +public: +//void handle_user_serial_message(char * message, char length, char interface); + +/** + * Sets the baud rates and enables the serial interfaces (PC and BT) as defined in the settings.h file + * Attaches listeners to both the serial ports that trigger when a message is received + */ +void setup_serial_interfaces(void); + +private: void IF_start_file_transfer_mode(void); void IF_end_file_transfer_mode(void); void IF_file_transfer_timeout(void); void IF_handle_file_transfer_serial_message(char * message, char length, char interface); void IF_handle_user_serial_message(char * message, char length, char interface); void IF_handle_command_serial_message(char message [3], char interface); -void IF_setup_serial_interfaces(void); +void IF_invalid_transfer(void); void IF_pc_rx_callback(void); void IF_bt_rx_callback(void); - +void IF_pc_rx_command_timeout(void); +void IF_bt_rx_command_timeout(void); +void IF_bt_message_timeout(void); char * IF_nibble_to_binary_char(char in); char * IF_char_to_binary_char(char in); float IF_decode_unsigned_float(char byte0, char byte1); @@ -44,6 +67,6 @@ float IF_decode_unsigned_float(char byte0); void IF_set_filename(char * filename_in); unsigned short IF_calculateCRC16(int file_length); - +}; #endif \ No newline at end of file