diff --git a/Makefile b/Makefile index 4bf8e3d2..fe08d0b4 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ OS ?= os/linux DESTDIR ?= BLD ?= bld -VERSION=0.5.0 +VERSION=0.5.1 ifeq ($(TINYCONF), nano) CONFIG_ENABLE_FCS32 ?= n @@ -142,6 +142,7 @@ SRC_TEST_ARDUINO_LIB = \ src/lib/crc.c \ src/lib/tiny_layer2.c \ src/arduino/src/TinyProtocol.cpp \ + src/arduino/src/TinyProtocolHd.cpp \ # src/lib/tiny_request_pool.c \ # src/lib/tiny_list.c \ diff --git a/docs/TinyPacket_8h.html b/docs/TinyPacket_8h.html index 59fbfdb0..cb011f27 100644 --- a/docs/TinyPacket_8h.html +++ b/docs/TinyPacket_8h.html @@ -24,7 +24,7 @@
Tiny protocol -  0.5 +  0.5.1
Tiny communication protocol for microcontrollers
@@ -109,7 +109,7 @@
- +

Go to the source code of this file.

diff --git a/docs/TinyPacket_8h__dep__incl.map b/docs/TinyPacket_8h__dep__incl.map index 2977744b..43467ebe 100644 --- a/docs/TinyPacket_8h__dep__incl.map +++ b/docs/TinyPacket_8h__dep__incl.map @@ -1,3 +1,4 @@ + diff --git a/docs/TinyPacket_8h__dep__incl.md5 b/docs/TinyPacket_8h__dep__incl.md5 index 49acddc2..1cc9b438 100644 --- a/docs/TinyPacket_8h__dep__incl.md5 +++ b/docs/TinyPacket_8h__dep__incl.md5 @@ -1 +1 @@ -d57767e574a645084b7a73f088cc8dad \ No newline at end of file +973d274b8507c889a8b870722bea1ddc \ No newline at end of file diff --git a/docs/TinyPacket_8h__dep__incl.png b/docs/TinyPacket_8h__dep__incl.png index 6eeff6ec..af06f94b 100644 Binary files a/docs/TinyPacket_8h__dep__incl.png and b/docs/TinyPacket_8h__dep__incl.png differ diff --git a/docs/TinyPacket_8h_source.html b/docs/TinyPacket_8h_source.html index d811d947..4c9a0724 100644 --- a/docs/TinyPacket_8h_source.html +++ b/docs/TinyPacket_8h_source.html @@ -24,7 +24,7 @@
Tiny protocol -  0.5 +  0.5.1
Tiny communication protocol for microcontrollers
@@ -174,23 +174,25 @@
189 
190 private:
191  friend class Proto;
-
192 
-
193  uint8_t* m_buf;
-
194  uint16_t m_uid;
-
195  uint8_t m_size;
-
196  uint8_t m_len;
-
197  uint8_t m_p;
-
198 };
-
199 
+
192  friend class ProtoHd;
+
193 
+
194  uint8_t* m_buf;
+
195  uint16_t m_uid;
+
196  uint8_t m_size;
+
197  uint8_t m_len;
+
198  uint8_t m_p;
+
199 };
200 
-
201 } // Tiny namespace
-
202 
-
203 #endif
-
204 
+
201 
+
202 } // Tiny namespace
+
203 
+
204 #endif
+
205 
Tiny::Packet::put
void put(uint8_t byte)
Definition: TinyPacket.h:64
Tiny::Packet::getUint16
uint16_t getUint16()
Definition: TinyPacket.h:132
Tiny
Definition: TinyPacket.h:37
Tiny::Packet::getUid
uint16_t getUid()
Definition: TinyPacket.h:159
+
Tiny::ProtoHd
Definition: TinyProtocolHd.h:49
Tiny::Packet::Packet
Packet(char *buf, size_t size)
Definition: TinyPacket.h:52
Tiny::Packet::getByte
uint8_t getByte()
Definition: TinyPacket.h:120
Tiny::Packet::putUid
void putUid(uint16_t uid)
Definition: TinyPacket.h:114
@@ -204,7 +206,7 @@
Tiny::Packet::put
void put(uint32_t data)
Definition: TinyPacket.h:84
Tiny::Packet::getString
char * getString()
Definition: TinyPacket.h:150
Tiny::Packet::getInt16
int16_t getInt16()
Definition: TinyPacket.h:138
-
Tiny::Proto
Definition: TinyProtocol.h:49
+
Tiny::Proto
Definition: TinyProtocol.h:47
Tiny::Packet::clear
void clear()
Definition: TinyPacket.h:57
Tiny::Packet::data
char * data()
Definition: TinyPacket.h:177
Tiny::Packet::size
size_t size()
Definition: TinyPacket.h:165
diff --git a/docs/TinyProtocolHd_8h.html b/docs/TinyProtocolHd_8h.html new file mode 100644 index 00000000..dd2b2dc9 --- /dev/null +++ b/docs/TinyProtocolHd_8h.html @@ -0,0 +1,128 @@ + + + + + + +Tiny protocol: src/arduino/src/TinyProtocolHd.h File Reference + + + + + + + + + + +
+
+ + + + + + +
+
Tiny protocol +  0.5.1 +
+
Tiny communication protocol for microcontrollers
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+Classes
+
+
TinyProtocolHd.h File Reference
+
+
+ +

Tiny protocol Arduino API. +More...

+
#include "TinyPacket.h"
+#include "proto/tiny_hd.h"
+#include <HardwareSerial.h>
+
+Include dependency graph for TinyProtocolHd.h:
+
+
+ + +
+
+

Go to the source code of this file.

+ + + + +

+Classes

class  Tiny::ProtoHd
 
+

Detailed Description

+

Tiny protocol Arduino API.

+

This is Tiny protocol implementation for microcontrollers

+
+ + + + diff --git a/docs/TinyProtocolHd_8h__incl.map b/docs/TinyProtocolHd_8h__incl.map new file mode 100644 index 00000000..f1947c22 --- /dev/null +++ b/docs/TinyProtocolHd_8h__incl.map @@ -0,0 +1,3 @@ + + + diff --git a/docs/TinyProtocolHd_8h__incl.md5 b/docs/TinyProtocolHd_8h__incl.md5 new file mode 100644 index 00000000..8fbf7e26 --- /dev/null +++ b/docs/TinyProtocolHd_8h__incl.md5 @@ -0,0 +1 @@ +da3142091a6ae1dc001cb01d45521465 \ No newline at end of file diff --git a/docs/TinyProtocolHd_8h__incl.png b/docs/TinyProtocolHd_8h__incl.png new file mode 100644 index 00000000..06b20456 Binary files /dev/null and b/docs/TinyProtocolHd_8h__incl.png differ diff --git a/docs/TinyProtocolHd_8h_source.html b/docs/TinyProtocolHd_8h_source.html new file mode 100644 index 00000000..08d73632 --- /dev/null +++ b/docs/TinyProtocolHd_8h_source.html @@ -0,0 +1,237 @@ + + + + + + +Tiny protocol: src/arduino/src/TinyProtocolHd.h Source File + + + + + + + + + + +
+
+ + + + + + +
+
Tiny protocol +  0.5.1 +
+
Tiny communication protocol for microcontrollers
+
+
+ + + + + + +
+
+ + +
+ +
+ + +
+
+
+
TinyProtocolHd.h
+
+
+Go to the documentation of this file.
1 /*
+
2  Copyright 2017 (C) Alexey Dynda
+
3 
+
4  This file is part of Tiny Protocol Library.
+
5 
+
6  Protocol Library is free software: you can redistribute it and/or modify
+
7  it under the terms of the GNU Lesser General Public License as published by
+
8  the Free Software Foundation, either version 3 of the License, or
+
9  (at your option) any later version.
+
10 
+
11  Protocol Library is distributed in the hope that it will be useful,
+
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
+
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+
14  GNU Lesser General Public License for more details.
+
15 
+
16  You should have received a copy of the GNU Lesser General Public License
+
17  along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
+
18 */
+
19 
+
28 #ifndef _TINY_PROTOCOL_H_
+
29 #define _TINY_PROTOCOL_H_
+
30 
+
31 #include "TinyPacket.h"
+
32 #include "proto/tiny_hd.h"
+
33 
+
34 #ifdef ARDUINO
+
35 # include <HardwareSerial.h>
+
36 #else
+
37 # include <string.h>
+
38 #endif
+
39 
+
40 namespace Tiny {
+
41 
+
49 class ProtoHd
+
50 {
+
51 private:
+
52  STinyHdData m_data;
+
53 
+
54 public:
+
55  inline ProtoHd(void * buffer,
+
56  int bufferSize,
+
57  void (*onReceive)(uint8_t *buf, int len))
+
58  {
+
59  m_buffer = buffer;
+
60  m_bufferSize = bufferSize;
+
61  m_onReceive = onReceive;
+
62  }
+
63 
+
72  void begin (write_block_cb_t writecb,
+
73  read_block_cb_t readcb);
+
74 
+
75 #ifdef ARDUINO
+
76 
+
81  inline void beginToSerial()
+
82  {
+
83  begin([](void *p, const uint8_t *b, int s)->int { return Serial.write(b, s); },
+
84  [](void *p, uint8_t *b, int s)->int { return Serial.readBytes(b, s); });
+
85  }
+
86 
+
87 #if HAVE_HWSERIAL1
+
88 
+
93  inline void beginToSerial1()
+
94  {
+
95  begin([](void *p, const uint8_t *b, int s)->int { return Serial1.write(b, s); },
+
96  [](void *p, uint8_t *b, int s)->int { return Serial1.readBytes(b, s); });
+
97  }
+
98 #endif
+
99 
+
100 #if HAVE_HWSERIAL2
+
101 
+
106  inline void beginToSerial2()
+
107  {
+
108  begin([](void *p, const uint8_t *b, int s)->int { return Serial2.write(b, s); },
+
109  [](void *p, uint8_t *b, int s)->int { return Serial2.readBytes(b, s); });
+
110  }
+
111 #endif
+
112 
+
113 #if HAVE_HWSERIAL3
+
114 
+
119  inline void beginToSerial3()
+
120  {
+
121  begin([](void *p, const uint8_t *b, int s)->int { return Serial3.write(b, s); },
+
122  [](void *p, uint8_t *b, int s)->int { return Serial3.readBytes(b, s); });
+
123  }
+
124 #endif
+
125 
+
126 #endif
+
127 
+
131  void end ();
+
132 
+
141  int write (char* buf, int size);
+
142 
+
151  int write (Packet &pkt);
+
152 
+
161  int run ();
+
162 
+
168  void disableCrc ();
+
169 
+
177  bool enableCheckSum ();
+
178 
+
186  bool enableCrc16 ();
+
187 
+
196  bool enableCrc32 ();
+
197 
+
198 private:
+
199  void *m_buffer;
+
200  int m_bufferSize;
+
201  void (*m_onReceive)(uint8_t *buf, int len);
+
202  static void onReceiveInternal(void *handle, uint16_t uid, uint8_t *pdata, int size);
+
203 
+
204 };
+
205 
+
206 
+
207 } // Tiny namespace
+
208 
+
209 #endif
+
210 
+
Tiny protocol Arduino API.
+
Definition: TinyPacket.h:37
+
void begin(write_block_cb_t writecb, read_block_cb_t readcb)
+
void beginToSerial()
Definition: TinyProtocolHd.h:81
+
Definition: TinyProtocolHd.h:49
+
void beginToSerial1()
Definition: TinyProtocolHd.h:93
+
int write(char *buf, int size)
+
void beginToSerial2()
Definition: TinyProtocolHd.h:106
+
void beginToSerial3()
Definition: TinyProtocolHd.h:119
+
bool enableCrc32()
+
int(* write_block_cb_t)(void *pdata, const uint8_t *buffer, int size)
Definition: tiny_layer2.h:112
+ + +
Definition: TinyPacket.h:43
+
void disableCrc()
+
bool enableCheckSum()
+
bool enableCrc16()
+
int(* read_block_cb_t)(void *pdata, uint8_t *buffer, int size)
Definition: tiny_layer2.h:123
+
+ + + + diff --git a/docs/TinyProtocol_8h.html b/docs/TinyProtocol_8h.html index cd482391..9f6b47c3 100644 --- a/docs/TinyProtocol_8h.html +++ b/docs/TinyProtocol_8h.html @@ -24,7 +24,7 @@
Tiny protocol -  0.5 +  0.5.1
Tiny communication protocol for microcontrollers
diff --git a/docs/TinyProtocol_8h_source.html b/docs/TinyProtocol_8h_source.html index 6524c04b..a1b88d0a 100644 --- a/docs/TinyProtocol_8h_source.html +++ b/docs/TinyProtocol_8h_source.html @@ -24,7 +24,7 @@
Tiny protocol -  0.5 +  0.5.1
Tiny communication protocol for microcontrollers
@@ -92,7 +92,7 @@
Go to the documentation of this file.
1 /*
-
2  Copyright 2016 (C) Alexey Dynda
+
2  Copyright 2016-2017 (C) Alexey Dynda
3 
4  This file is part of Tiny Protocol Library.
5 
@@ -124,85 +124,83 @@
39 
40 namespace Tiny {
41 
-
42 class Packet;
-
43 
-
49 class Proto
-
50 {
-
51 public:
-
52  inline Proto() { m_uidEnabled = false; }
-
53 
-
62  void begin (write_block_cb_t writecb,
-
63  read_block_cb_t readcb);
+
47 class Proto
+
48 {
+
49 public:
+
50  inline Proto() { m_uidEnabled = false; }
+
51 
+
60  void begin (write_block_cb_t writecb,
+
61  read_block_cb_t readcb);
+
62 
+
63 #ifdef ARDUINO
64 
-
65 #ifdef ARDUINO
-
66 
-
71  inline void beginToSerial()
-
72  {
-
73  begin([](void *p, const uint8_t *b, int s)->int { return Serial.write(b, s); },
-
74  [](void *p, uint8_t *b, int s)->int { return Serial.readBytes(b, s); });
-
75  }
+
69  inline void beginToSerial()
+
70  {
+
71  begin([](void *p, const uint8_t *b, int s)->int { return Serial.write(b, s); },
+
72  [](void *p, uint8_t *b, int s)->int { return Serial.readBytes(b, s); });
+
73  }
+
74 
+
75 #if HAVE_HWSERIAL1
76 
-
77 #if HAVE_HWSERIAL1
-
78 
-
83  inline void beginToSerial1()
-
84  {
-
85  begin([](void *p, const uint8_t *b, int s)->int { return Serial1.write(b, s); },
-
86  [](void *p, uint8_t *b, int s)->int { return Serial1.readBytes(b, s); });
-
87  }
-
88 #endif
+
81  inline void beginToSerial1()
+
82  {
+
83  begin([](void *p, const uint8_t *b, int s)->int { return Serial1.write(b, s); },
+
84  [](void *p, uint8_t *b, int s)->int { return Serial1.readBytes(b, s); });
+
85  }
+
86 #endif
+
87 
+
88 #if HAVE_HWSERIAL2
89 
-
90 #if HAVE_HWSERIAL2
-
91 
-
96  inline void beginToSerial2()
-
97  {
-
98  begin([](void *p, const uint8_t *b, int s)->int { return Serial2.write(b, s); },
-
99  [](void *p, uint8_t *b, int s)->int { return Serial2.readBytes(b, s); });
-
100  }
-
101 #endif
+
94  inline void beginToSerial2()
+
95  {
+
96  begin([](void *p, const uint8_t *b, int s)->int { return Serial2.write(b, s); },
+
97  [](void *p, uint8_t *b, int s)->int { return Serial2.readBytes(b, s); });
+
98  }
+
99 #endif
+
100 
+
101 #if HAVE_HWSERIAL3
102 
-
103 #if HAVE_HWSERIAL3
-
104 
-
109  inline void beginToSerial3()
-
110  {
-
111  begin([](void *p, const uint8_t *b, int s)->int { return Serial3.write(b, s); },
-
112  [](void *p, uint8_t *b, int s)->int { return Serial3.readBytes(b, s); });
-
113  }
+
107  inline void beginToSerial3()
+
108  {
+
109  begin([](void *p, const uint8_t *b, int s)->int { return Serial3.write(b, s); },
+
110  [](void *p, uint8_t *b, int s)->int { return Serial3.readBytes(b, s); });
+
111  }
+
112 #endif
+
113 
114 #endif
115 
-
116 #endif
-
117 
-
121  void end ();
-
122 
-
132  int write (char* buf, int size, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
-
133 
-
143  int read (char* buf, int size, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
-
144 
-
154  int write (Packet &pkt, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
-
155 
-
165  int read (Packet &pkt, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
-
166 
-
172  void disableCrc ();
-
173 
-
181  bool enableCheckSum ();
-
182 
-
190  bool enableCrc16 ();
-
191 
-
200  bool enableCrc32 ();
-
201 
-
208  inline void enableUid() { m_uidEnabled = true; }
-
209 
-
216  inline void disableUid(){ m_uidEnabled = false; }
-
217 
-
218 private:
-
219  STinyData m_data;
-
220  uint8_t m_uidEnabled;
-
221 };
-
222 
+
119  void end ();
+
120 
+
130  int write (char* buf, int size, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
+
131 
+
141  int read (char* buf, int size, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
+
142 
+
152  int write (Packet &pkt, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
+
153 
+
163  int read (Packet &pkt, uint8_t flags = TINY_FLAG_WAIT_FOREVER);
+
164 
+
170  void disableCrc ();
+
171 
+
179  bool enableCheckSum ();
+
180 
+
188  bool enableCrc16 ();
+
189 
+
198  bool enableCrc32 ();
+
199 
+
206  inline void enableUid() { m_uidEnabled = true; }
+
207 
+
214  inline void disableUid(){ m_uidEnabled = false; }
+
215 
+
216 private:
+
217  STinyData m_data;
+
218  uint8_t m_uidEnabled;
+
219 };
+
220 
+
221 
+
222 } // Tiny namespace
223 
-
224 } // Tiny namespace
+
224 #endif
225 
-
226 #endif
-
227 
bool enableCrc32()
int read(char *buf, int size, uint8_t flags=TINY_FLAG_WAIT_FOREVER)
Tiny protocol Arduino API.
@@ -210,20 +208,20 @@
Definition: TinyPacket.h:37
bool enableCrc16()
Definition: tiny_layer2.h:215
-
void beginToSerial()
Definition: TinyProtocol.h:71
+
void beginToSerial()
Definition: TinyProtocol.h:69
int(* write_block_cb_t)(void *pdata, const uint8_t *buffer, int size)
Definition: tiny_layer2.h:112
-
void beginToSerial3()
Definition: TinyProtocol.h:109
+
void beginToSerial3()
Definition: TinyProtocol.h:107
Definition: TinyPacket.h:43
-
void enableUid()
Definition: TinyProtocol.h:208
+
void enableUid()
Definition: TinyProtocol.h:206
void begin(write_block_cb_t writecb, read_block_cb_t readcb)
bool enableCheckSum()
-
void disableUid()
Definition: TinyProtocol.h:216
+
void disableUid()
Definition: TinyProtocol.h:214
int write(char *buf, int size, uint8_t flags=TINY_FLAG_WAIT_FOREVER)
-
Definition: TinyProtocol.h:49
+
Definition: TinyProtocol.h:47
void disableCrc()
-
void beginToSerial1()
Definition: TinyProtocol.h:83
-
void beginToSerial2()
Definition: TinyProtocol.h:96
+
void beginToSerial1()
Definition: TinyProtocol.h:81
+
void beginToSerial2()
Definition: TinyProtocol.h:94
int(* read_block_cb_t)(void *pdata, uint8_t *buffer, int size)
Definition: tiny_layer2.h:123
diff --git a/docs/annotated.html b/docs/annotated.html index 53cbd088..9eedd54c 100644 --- a/docs/annotated.html +++ b/docs/annotated.html @@ -24,7 +24,7 @@
Tiny protocol -  0.5 +  0.5.1
Tiny communication protocol for microcontrollers
@@ -93,12 +93,13 @@  NTiny  CPacket  CProto - Clist_element_Structure defines base type for the lists - CSTinyData - CSTinyRxStatus - CSTinyStats - CSTinyTxStatus - Ctiny_request_Defines type for tiny request list item + CProtoHd + Clist_element_Structure defines base type for the lists + CSTinyData + CSTinyRxStatus + CSTinyStats + CSTinyTxStatus + Ctiny_request_Defines type for tiny request list item diff --git a/docs/classTiny_1_1Packet-members.html b/docs/classTiny_1_1Packet-members.html index a9287081..8da4ee04 100644 --- a/docs/classTiny_1_1Packet-members.html +++ b/docs/classTiny_1_1Packet-members.html @@ -24,7 +24,7 @@
Tiny protocol -  0.5 +  0.5.1
Tiny communication protocol for microcontrollers
@@ -109,15 +109,16 @@ operator[](size_t idx)Tiny::Packetinline Packet(char *buf, size_t size)Tiny::Packetinline Proto (defined in Tiny::Packet)Tiny::Packetfriend - put(uint8_t byte)Tiny::Packetinline - put(char chr)Tiny::Packetinline - put(uint16_t data)Tiny::Packetinline - put(uint32_t data)Tiny::Packetinline - put(int16_t data)Tiny::Packetinline - put(const char *str)Tiny::Packetinline - put(const Packet &pkt)Tiny::Packetinline - putUid(uint16_t uid)Tiny::Packetinline - size()Tiny::Packetinline + ProtoHd (defined in Tiny::Packet)Tiny::Packetfriend + put(uint8_t byte)Tiny::Packetinline + put(char chr)Tiny::Packetinline + put(uint16_t data)Tiny::Packetinline + put(uint32_t data)Tiny::Packetinline + put(int16_t data)Tiny::Packetinline + put(const char *str)Tiny::Packetinline + put(const Packet &pkt)Tiny::Packetinline + putUid(uint16_t uid)Tiny::Packetinline + size()Tiny::Packetinline