APM:Libraries
BetterStream.h
Go to the documentation of this file.
1 /*
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License as published by
4  the Free Software Foundation, either version 3 of the License, or
5  (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program. If not, see <http://www.gnu.org/licenses/>.
14  */
15 
16 //
17 // Copyright (c) 2010 Michael Smith. All rights reserved.
18 //
19 //
20 #pragma once
21 
22 #include <stdarg.h>
23 
24 #include <AP_Common/AP_Common.h>
26 
28 public:
29 
30  virtual void printf(const char *, ...) FMT_PRINTF(2, 3);
31  virtual void vprintf(const char *, va_list);
32 
33  void print(const char *str) { write(str); }
34  void println(const char *str) { printf("%s\r\n", str); }
35 
36  virtual size_t write(uint8_t) = 0;
37  virtual size_t write(const uint8_t *buffer, size_t size);
38  size_t write(const char *str);
39 
40  virtual uint32_t available() = 0;
41 
42  /* return value for read():
43  * -1 if nothing available, uint8_t value otherwise. */
44  virtual int16_t read() = 0;
45 
46  /* NB txspace was traditionally a member of BetterStream in the
47  * FastSerial library. As far as concerns go, it belongs with available() */
48  virtual uint32_t txspace() = 0;
49 };
static uint8_t buffer[SRXL_FRAMELEN_MAX]
Definition: srxl.cpp:56
virtual uint32_t txspace()=0
#define FMT_PRINTF(a, b)
Definition: AP_Common.h:39
virtual void printf(const char *,...) FMT_PRINTF(2
Definition: BetterStream.cpp:5
virtual size_t write(uint8_t)=0
void println(const char *str)
Definition: BetterStream.h:34
void print(const char *str)
Definition: BetterStream.h:33
virtual int16_t read()=0
Common definitions and utility routines for the ArduPilot libraries.
virtual uint32_t available()=0
virtual void virtual void vprintf(const char *, va_list)