|
| 1 | +// #include "./BinaryIOUnbuffered.h" |
| 2 | + |
| 3 | +// BinaryIOUnbuffered::BinaryIOUnbuffered(Stream& io) : _io(io) { |
| 4 | +// // nothing to do here |
| 5 | +// }; |
| 6 | + |
| 7 | +// BinaryIOUnbuffered::~BinaryIOUnbuffered(){ |
| 8 | +// // nothing to do here |
| 9 | +// }; |
| 10 | + |
| 11 | + |
| 12 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator<<(float value) { |
| 13 | +// _io.write((uint8_t*)&value, 4); |
| 14 | +// return *this; |
| 15 | +// }; |
| 16 | + |
| 17 | + |
| 18 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator<<(uint32_t value) { |
| 19 | +// _io.write((uint8_t*)&value, 4); |
| 20 | +// return *this; |
| 21 | +// }; |
| 22 | + |
| 23 | + |
| 24 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator<<(uint8_t value) { |
| 25 | +// _io.write(value); |
| 26 | +// return *this; |
| 27 | +// }; |
| 28 | + |
| 29 | + |
| 30 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator<<(char value) { |
| 31 | +// _io.write((uint8_t)value); |
| 32 | +// return *this; |
| 33 | +// }; |
| 34 | + |
| 35 | + |
| 36 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator<<(Packet value) { |
| 37 | +// if (value.type!=0x00) { |
| 38 | +// _io.write(MARKER_BYTE); |
| 39 | +// _io.write(value.payload_size+1); |
| 40 | +// _io.write(value.type); |
| 41 | +// } |
| 42 | +// return *this; |
| 43 | +// }; |
| 44 | + |
| 45 | + |
| 46 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator<<(Separator value) { |
| 47 | +// // separator is ignored in binary mode |
| 48 | +// return *this; |
| 49 | +// }; |
| 50 | + |
| 51 | + |
| 52 | +// // Immediate flush - no buffering, so nothing to do |
| 53 | +// void BinaryIOUnbuffered::_flush() { |
| 54 | +// // No internal buffer to flush |
| 55 | +// }; |
| 56 | + |
| 57 | + |
| 58 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator>>(float &value) { |
| 59 | +// remaining -= _io.readBytes((uint8_t*)&value, 4); |
| 60 | +// return *this; |
| 61 | +// }; |
| 62 | + |
| 63 | + |
| 64 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator>>(uint32_t &value) { |
| 65 | +// remaining -= _io.readBytes((uint8_t*)&value, 4); |
| 66 | +// return *this; |
| 67 | +// }; |
| 68 | + |
| 69 | + |
| 70 | +// BinaryIOUnbuffered& BinaryIOUnbuffered::operator>>(uint8_t &value) { |
| 71 | +// value = (uint8_t)_io.read(); |
| 72 | +// remaining--; |
| 73 | +// return *this; |
| 74 | +// }; |
| 75 | + |
| 76 | + |
| 77 | +// PacketIO& BinaryIOUnbuffered::operator>>(Packet& value) { |
| 78 | +// while (!in_sync && _io.available() > 0) { |
| 79 | +// if (_io.peek() == MARKER_BYTE) |
| 80 | +// in_sync = true; |
| 81 | +// else |
| 82 | +// _io.read(); |
| 83 | +// } |
| 84 | +// if (_io.peek() == MARKER_BYTE) { |
| 85 | +// _io.read(); // discard the marker |
| 86 | +// } |
| 87 | +// if (!in_sync || _io.available() < 3) { // size, frame type, payload = 3 bytes minimum frame size |
| 88 | +// value.type = 0x00; |
| 89 | +// value.payload_size = 0; |
| 90 | +// return *this; |
| 91 | +// } |
| 92 | +// value.payload_size = (uint8_t)_io.read() - 1; |
| 93 | +// value.type = (uint8_t)_io.read(); |
| 94 | +// remaining = value.payload_size; |
| 95 | +// return *this; |
| 96 | +// }; |
| 97 | + |
| 98 | +// bool BinaryIOUnbuffered::is_complete() { |
| 99 | +// return (remaining <= 0); |
| 100 | +// }; |
0 commit comments