Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PsiSwarmV9 by
serial.h@20:2b6ebe60929d, 2019-07-08 (annotated)
- Committer:
- richardredpath
- Date:
- Mon Jul 08 10:50:40 2019 +0000
- Revision:
- 20:2b6ebe60929d
- Parent:
- 16:50686c07ad07
Fixed deprecated warnings for callbacks throughout the library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jah128 | 0:d6269d17c8cf | 1 | /* University of York Robotics Laboratory PsiSwarm Library: Serial Control Header File |
jah128 | 0:d6269d17c8cf | 2 | * |
jah128 | 16:50686c07ad07 | 3 | * Copyright 2017 University of York |
jah128 | 6:b340a527add9 | 4 | * |
jah128 | 6:b340a527add9 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. |
jah128 | 6:b340a527add9 | 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 |
jah128 | 6:b340a527add9 | 7 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS |
jah128 | 6:b340a527add9 | 8 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
jah128 | 6:b340a527add9 | 9 | * See the License for the specific language governing permissions and limitations under the License. |
jah128 | 6:b340a527add9 | 10 | * |
jah128 | 0:d6269d17c8cf | 11 | * File: serial.h |
jah128 | 0:d6269d17c8cf | 12 | * |
jah128 | 0:d6269d17c8cf | 13 | * (C) Dept. Electronics & Computer Science, University of York |
jah128 | 0:d6269d17c8cf | 14 | * James Hilder, Alan Millard, Alexander Horsfield, Homero Elizondo, Jon Timmis |
jah128 | 0:d6269d17c8cf | 15 | * |
jah128 | 16:50686c07ad07 | 16 | * PsiSwarm Library Version: 0.9 |
jah128 | 0:d6269d17c8cf | 17 | * |
jah128 | 16:50686c07ad07 | 18 | * June 2017 |
jah128 | 0:d6269d17c8cf | 19 | * |
jah128 | 0:d6269d17c8cf | 20 | * |
jah128 | 0:d6269d17c8cf | 21 | */ |
jah128 | 0:d6269d17c8cf | 22 | |
jah128 | 0:d6269d17c8cf | 23 | |
jah128 | 0:d6269d17c8cf | 24 | #ifndef SERIAL_H |
jah128 | 0:d6269d17c8cf | 25 | #define SERIAL_H |
jah128 | 0:d6269d17c8cf | 26 | |
jah128 | 11:312663037b8c | 27 | /** |
jah128 | 11:312663037b8c | 28 | * SerialControl class |
jah128 | 11:312663037b8c | 29 | * Functions to handle command and user messages sent over the PC or BT serial interfaces. Most of the functions within this class |
jah128 | 11:312663037b8c | 30 | * are not intended to be called by user applications; once the setup_serial_interfaces() function has been called the enabled |
jah128 | 11:312663037b8c | 31 | * serial ports are attached to listeners which handle any received messages. A predefined message structure for commands has been |
jah128 | 11:312663037b8c | 32 | * created which allows most functions on the robot to be externally called, either using a PC-robot or Bluetooth connection. |
jah128 | 11:312663037b8c | 33 | * |
jah128 | 11:312663037b8c | 34 | * For user functions, the main.cpp file should include a void handle_user_serial_message(char * message, char length, char interface) |
jah128 | 11:312663037b8c | 35 | * function to handle user-defined messages. |
jah128 | 11:312663037b8c | 36 | * |
jah128 | 11:312663037b8c | 37 | */ |
jah128 | 11:312663037b8c | 38 | class SerialControl |
jah128 | 11:312663037b8c | 39 | { |
jah128 | 11:312663037b8c | 40 | public: |
jah128 | 11:312663037b8c | 41 | //void handle_user_serial_message(char * message, char length, char interface); |
jah128 | 11:312663037b8c | 42 | |
jah128 | 11:312663037b8c | 43 | /** |
jah128 | 11:312663037b8c | 44 | * Sets the baud rates and enables the serial interfaces (PC and BT) as defined in the settings.h file |
jah128 | 11:312663037b8c | 45 | * Attaches listeners to both the serial ports that trigger when a message is received |
jah128 | 11:312663037b8c | 46 | */ |
jah128 | 11:312663037b8c | 47 | void setup_serial_interfaces(void); |
jah128 | 11:312663037b8c | 48 | |
jah128 | 11:312663037b8c | 49 | private: |
jah128 | 1:060690a934a9 | 50 | void IF_start_file_transfer_mode(void); |
jah128 | 1:060690a934a9 | 51 | void IF_end_file_transfer_mode(void); |
jah128 | 1:060690a934a9 | 52 | void IF_file_transfer_timeout(void); |
jah128 | 0:d6269d17c8cf | 53 | void IF_handle_file_transfer_serial_message(char * message, char length, char interface); |
jah128 | 0:d6269d17c8cf | 54 | void IF_handle_user_serial_message(char * message, char length, char interface); |
jah128 | 0:d6269d17c8cf | 55 | void IF_handle_command_serial_message(char message [3], char interface); |
jah128 | 11:312663037b8c | 56 | void IF_invalid_transfer(void); |
jah128 | 0:d6269d17c8cf | 57 | void IF_pc_rx_callback(void); |
jah128 | 0:d6269d17c8cf | 58 | void IF_bt_rx_callback(void); |
jah128 | 11:312663037b8c | 59 | void IF_pc_rx_command_timeout(void); |
jah128 | 11:312663037b8c | 60 | void IF_bt_rx_command_timeout(void); |
jah128 | 11:312663037b8c | 61 | void IF_bt_message_timeout(void); |
jah128 | 0:d6269d17c8cf | 62 | char * IF_nibble_to_binary_char(char in); |
jah128 | 0:d6269d17c8cf | 63 | char * IF_char_to_binary_char(char in); |
jah128 | 0:d6269d17c8cf | 64 | float IF_decode_unsigned_float(char byte0, char byte1); |
jah128 | 0:d6269d17c8cf | 65 | float IF_decode_float(char byte0, char byte1); |
jah128 | 0:d6269d17c8cf | 66 | float IF_decode_float(char byte0); |
jah128 | 0:d6269d17c8cf | 67 | float IF_decode_unsigned_float(char byte0); |
jah128 | 2:c6986ee3c7c5 | 68 | void IF_set_filename(char * filename_in); |
jah128 | 2:c6986ee3c7c5 | 69 | unsigned short IF_calculateCRC16(int file_length); |
jah128 | 11:312663037b8c | 70 | }; |
jah128 | 0:d6269d17c8cf | 71 | |
jah128 | 0:d6269d17c8cf | 72 | #endif |