source: rtos_arduino/trunk/arduino_lib/libraries/Bridge/src/Console.h@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 1.8 KB
Line 
1/*
2 Copyright (c) 2013 Arduino LLC. All right reserved.
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#ifndef CONSOLE_H_
20#define CONSOLE_H_
21
22#include <Bridge.h>
23
24class ConsoleClass : public Stream {
25 public:
26 // Default constructor uses global Bridge instance
27 ConsoleClass();
28 // Constructor with a user provided BridgeClass instance
29 ConsoleClass(BridgeClass &_b);
30 ~ConsoleClass();
31
32 void begin();
33 void end();
34
35 void buffer(uint8_t size);
36 void noBuffer();
37
38 bool connected();
39
40 // Stream methods
41 // (read from console socket)
42 int available();
43 int read();
44 int peek();
45 // (write to console socket)
46 size_t write(uint8_t);
47 size_t write(const uint8_t *buffer, size_t size);
48 void flush();
49
50 operator bool () {
51 return connected();
52 }
53
54 private:
55 BridgeClass &bridge;
56
57 void doBuffer();
58 uint8_t inBuffered;
59 uint8_t inReadPos;
60 static const int BUFFER_SIZE = 32;
61 uint8_t *inBuffer;
62
63 bool autoFlush;
64 uint8_t outBuffered;
65 uint8_t outBufferSize;
66 uint8_t *outBuffer;
67};
68
69extern ConsoleClass Console;
70
71#endif
Note: See TracBrowser for help on using the repository browser.