C++ Library for the PsiSwarm Robot - Version 0.8

Dependents:   PsiSwarm_V8_Blank_CPP Autonomia_RndmWlk

Fork of PsiSwarmV7_CPP by Psi Swarm Robot

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers serial.h Source File

serial.h

00001 /* University of York Robotics Laboratory PsiSwarm Library: Serial Control Header File
00002  * 
00003  * Copyright 2016 University of York
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
00006  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
00007  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS
00008  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
00009  * See the License for the specific language governing permissions and limitations under the License.
00010  *
00011  * File: serial.h
00012  *
00013  * (C) Dept. Electronics & Computer Science, University of York
00014  * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis
00015  *
00016  * PsiSwarm Library Version: 0.8
00017  *
00018  * October 2016
00019  *
00020  *
00021  */ 
00022  
00023  
00024 #ifndef SERIAL_H
00025 #define SERIAL_H
00026 
00027 /**
00028  * SerialControl class
00029  * Functions to handle command and user messages sent over the PC or BT serial interfaces.  Most of the functions within this class
00030  * are not intended to be called by user applications; once the setup_serial_interfaces() function has been called the enabled 
00031  * serial ports are attached to listeners which handle any received messages.  A predefined message structure for commands has been
00032  * created which allows most functions on the robot to be externally called, either using a PC-robot or Bluetooth connection.
00033  *
00034  * For user functions, the main.cpp file should include a void handle_user_serial_message(char * message, char length, char interface)
00035  * function to handle user-defined messages.
00036  *
00037 */
00038 class SerialControl
00039 {
00040 public:
00041 //void handle_user_serial_message(char * message, char length, char interface);
00042 
00043 /**
00044  *  Sets the baud rates and enables the serial interfaces (PC and BT) as defined in the settings.h file
00045  *  Attaches listeners to both the serial ports that trigger when a message is received
00046  */
00047 void setup_serial_interfaces(void);
00048 
00049 private:
00050 void IF_start_file_transfer_mode(void);
00051 void IF_end_file_transfer_mode(void);
00052 void IF_file_transfer_timeout(void);
00053 void IF_handle_file_transfer_serial_message(char * message, char length, char interface);
00054 void IF_handle_user_serial_message(char * message, char length, char interface);
00055 void IF_handle_command_serial_message(char message [3], char interface);
00056 void IF_invalid_transfer(void);
00057 void IF_pc_rx_callback(void);
00058 void IF_bt_rx_callback(void);
00059 void IF_pc_rx_command_timeout(void);
00060 void IF_bt_rx_command_timeout(void);
00061 void IF_bt_message_timeout(void);
00062 char * IF_nibble_to_binary_char(char in);
00063 char * IF_char_to_binary_char(char in);
00064 float IF_decode_unsigned_float(char byte0, char byte1);
00065 float IF_decode_float(char byte0, char byte1);
00066 float IF_decode_float(char byte0);
00067 float IF_decode_unsigned_float(char byte0);
00068 void IF_set_filename(char * filename_in);
00069 unsigned short IF_calculateCRC16(int file_length);
00070 };
00071 
00072 #endif