From 615215d3137d6bd753cbd855928a4dbea105fd05 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sun, 20 Aug 2017 15:27:52 +0200 Subject: stream --- car/common.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 car/common.cpp (limited to 'car/common.cpp') diff --git a/car/common.cpp b/car/common.cpp deleted file mode 100644 index 7b5522f..0000000 --- a/car/common.cpp +++ /dev/null @@ -1,38 +0,0 @@ -//#include -#include -#include "pb_encode.h" -#include "pb_decode.h" - -#define MAXSZ 32 - -bool -write_callback(pb_ostream_t *stream, const uint8_t *buf, size_t count) -{ - int result = Serial.write(buf, count); -// Serial.flush(); - return result == count; -} - -bool -read_callback(pb_istream_t *stream, uint8_t *buf, size_t count) -{ - int result = Serial.readBytes(buf, count); - if (result == 0) { - stream->bytes_left = 0; // EOF - } - return result == count; -} - -pb_ostream_t -pb_ostream_from_serial() -{ - pb_ostream_t stream = {write_callback, NULL, MAXSZ, 0}; - return stream; -} - -pb_istream_t -pb_istream_from_serial() -{ - pb_istream_t stream = {read_callback, NULL, MAXSZ}; - return stream; -} -- cgit v1.2.3