Skip to content

Commit

Permalink
Fix compile errors for Arduino
Browse files Browse the repository at this point in the history
  • Loading branch information
siara-cc committed Jul 22, 2024
1 parent c427ffd commit a20a716
Show file tree
Hide file tree
Showing 6 changed files with 729 additions and 299 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ unishox
unishox1
!unishox1/
usx3
u3b
tex/.*
unishox2
unishox++_0_1_0
Expand Down
22 changes: 22 additions & 0 deletions Arduino/Arduino.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Example sketch to demonstrate use of buffer size limiting for compression and decompression
#include "unishox2.h"
#include <Arduino.h>

void setup() {
Serial.begin(115200);
char cbuf[8]; // Restrict buffer size to check that it does not overflow
char dbuf[8];
int clen, dlen;
clen = unishox2_compress_lines("Hello World", 11, cbuf, sizeof(cbuf) - 1, USX_PSET_DFLT, NULL);
clen = 8; // clen would have been -1 since buffer was not sufficient
dlen = unishox2_decompress_lines(cbuf, clen, dbuf, sizeof(dbuf) - 1, USX_PSET_DFLT, NULL);
dlen = 7;
dbuf[dlen] = '\0';
Serial.print("Decompressed output: ");
Serial.println(dbuf);
}

void loop() {
// put your main code here, to run repeatedly:

}
Loading

0 comments on commit a20a716

Please sign in to comment.