File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed
Cbor/Examples/Cbor_Serialport_sender Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,8 @@ void testSerialPort() {
3636 unsigned char *datapkg = output.getData ();
3737
3838 // print in Serial port the Data length and Cbor in binary
39- Serial.print (" datalength:" );
40- Serial.println (datalength);
39+ // Serial.print("datalength:");
40+ Serial.print (datalength);
4141 Serial.write (*datapkg,datalength);
4242}
4343
Original file line number Diff line number Diff line change 1+ /*
2+
3+ Arduino Sketch to show how Send Encode Cbor package via Serial port
4+
5+ Author: Juanjo Tara
6+ email: j.tara@arduino.cc
7+ date: 24/04/2015
8+ */
9+
10+
11+ #include "CborEncoder.h"
12+
13+
14+
15+ void setup() {
16+ Serial.begin(9600);
17+
18+ }
19+
20+ void loop() {
21+
22+ testSerialPort();
23+ delay(10000);
24+
25+ }
26+
27+ void testSerialPort() {
28+ CborStaticOutput output(32);
29+ CborWriter writer(output);
30+ //Write a Cbor Package with a number and String
31+ writer.writeInt(124);
32+ writer.writeString("I");
33+
34+ //get length and data of cbor package
35+ unsigned int datalength = output.getSize();
36+ unsigned char *datapkg = output.getData();
37+
38+ //print in Serial port the Data length and Cbor in binary
39+ //Serial.print("datalength:");
40+ Serial.println(datalength);
41+ Serial.write(*datapkg,datalength);
42+ }
43+
44+
You can’t perform that action at this time.
0 commit comments