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

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

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

File size: 1.9 KB
Line 
1/*
2****************************************************************************
3* Copyright (c) 2015 Arduino srl. All right reserved.
4*
5* File : Ciao.h
6* Date : 2015/09/17
7* Revision : 0.0.1 $
8* Author: andrea[at]arduino[dot]org
9*
10****************************************************************************
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2.1 of the License, or (at your option) any later version.
16
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
21
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25*/
26
27#ifndef BRIDGE_H_
28#define BRIDGE_H_
29
30#include <Arduino.h>
31#include <CiaoData.h>
32#include <Stream.h>
33
34class CiaoClass {
35 public:
36 CiaoClass(Stream &_stream);
37 void begin();
38 CiaoData read(String);
39 void write( String protocol, String param1, String param2 = "", String param3 = "");
40 void writeResponse( String protocol, String id, String param1="", String param2 = "", String param3 = "");
41 CiaoData parse(String, String);
42
43 private:
44 void dropAll();
45 Stream &stream;
46 bool started;
47};
48
49// This subclass uses a serial port Stream
50class SerialCiaoClass : public CiaoClass {
51 public:
52 SerialCiaoClass(HardwareSerial &_serial)
53 : CiaoClass(_serial), serial(_serial) {
54 // Empty
55 }
56 void begin( unsigned long baudrate = 250000) {
57 serial.begin(baudrate);
58 CiaoClass::begin();
59 }
60
61 private:
62 HardwareSerial &serial;
63};
64
65void splitString(String, String, String[], int size);
66
67extern SerialCiaoClass Ciao;
68
69#endif /* BRIDGE_H_ */
Note: See TracBrowser for help on using the repository browser.