2013-08-29 02:34:34 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2012-08-20 18:37:21 -03:00
|
|
|
//
|
|
|
|
// Copyright (c) 2010 Michael Smith. All rights reserved.
|
|
|
|
//
|
|
|
|
//
|
2016-02-17 21:25:25 -04:00
|
|
|
#pragma once
|
2012-08-20 18:37:21 -03:00
|
|
|
|
2012-12-19 18:00:41 -04:00
|
|
|
#include <stdarg.h>
|
2012-08-20 20:54:01 -03:00
|
|
|
|
2015-10-25 17:31:40 -03:00
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
#include <AP_HAL/AP_HAL_Namespace.h>
|
2012-08-20 20:54:01 -03:00
|
|
|
|
2018-03-22 03:53:32 -03:00
|
|
|
class AP_HAL::BetterStream {
|
2012-08-20 18:37:21 -03:00
|
|
|
public:
|
|
|
|
|
2018-03-22 03:53:32 -03:00
|
|
|
virtual void printf(const char *, ...) FMT_PRINTF(2, 3);
|
|
|
|
virtual void vprintf(const char *, va_list);
|
|
|
|
|
|
|
|
void print(const char *str) { write(str); }
|
|
|
|
void println(const char *str) { printf("%s\r\n", str); }
|
|
|
|
|
|
|
|
virtual size_t write(uint8_t) = 0;
|
|
|
|
virtual size_t write(const uint8_t *buffer, size_t size);
|
|
|
|
size_t write(const char *str);
|
|
|
|
|
|
|
|
virtual uint32_t available() = 0;
|
|
|
|
|
|
|
|
/* return value for read():
|
|
|
|
* -1 if nothing available, uint8_t value otherwise. */
|
|
|
|
virtual int16_t read() = 0;
|
|
|
|
|
|
|
|
/* NB txspace was traditionally a member of BetterStream in the
|
|
|
|
* FastSerial library. As far as concerns go, it belongs with available() */
|
|
|
|
virtual uint32_t txspace() = 0;
|
2012-08-20 18:37:21 -03:00
|
|
|
};
|