source: rtos_arduino/trunk/arduino_lib/libraries/pubsubclient-2.6/tests/src/lib/Stream.cpp@ 209

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

BlueMix用のフィアルを追加

File size: 803 bytes
Line 
1#include "Stream.h"
2#include "trace.h"
3#include <iostream>
4#include <Arduino.h>
5
6Stream::Stream() {
7 this->expectBuffer = new Buffer();
8 this->_error = false;
9 this->_written = 0;
10}
11
12size_t Stream::write(uint8_t b) {
13 this->_written++;
14 TRACE(std::hex << (unsigned int)b);
15 if (this->expectBuffer->available()) {
16 uint8_t expected = this->expectBuffer->next();
17 if (expected != b) {
18 this->_error = true;
19 TRACE("!=" << (unsigned int)expected);
20 }
21 } else {
22 this->_error = true;
23 }
24 TRACE("\n"<< std::dec);
25 return 1;
26}
27
28
29bool Stream::error() {
30 return this->_error;
31}
32
33void Stream::expect(uint8_t *buf, size_t size) {
34 this->expectBuffer->add(buf,size);
35}
36
37uint16_t Stream::length() {
38 return this->_written;
39}
Note: See TracBrowser for help on using the repository browser.