Code Monkey home page Code Monkey logo

jandrassy / streamlib Goto Github PK

View Code? Open in Web Editor NEW
25.0 5.0 4.0 93 KB

Arduino library with Stream helper classes. BufferedPrint stream for efficient networking. ChunkedPrint for HTTP chunked encoding. ChunkedStreamReader for HTTP chunked decoding. CStringBulder builds a c-string with Print class methods. StringReadStream to wrap string as Stream. And printf() function with formatting string from F macro.

License: GNU Affero General Public License v3.0

C++ 96.52% C 3.48%
arduino-library streams buffering string-manipulation printf http

streamlib's Introduction

Hi there ๐Ÿ‘‹

I am a professional software engineer, but most of the repositories here are related to my hobby Arduino.

If you want to say thank you with a donation, you can Buy Me A Coffee or use PayPal Donate with PayPal

streamlib's People

Contributors

jandrassy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

streamlib's Issues

Getting a compile error

Hey I'm getting the following compile error when using it with PlatformIo.
Is this issue related to myself or sth. with the library?

.pio/libdeps/nano33iot/StreamLib/src/ChunkedPrint.cpp:55:20: error: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'char*' [-fpermissive]

He is complaining about this line of code:

sprintf_P(buffer - l, (firstChunk ? PSTR("%x\r") : PSTR("\r\n%x\r")), pos);

When I comment out this line, everything compiles, like I would expect it.

What information do you need to help me out here?

warning: unused parameter

Version 1.3.1 throws two warnings in Arduino IDE 1.8.19 for Arduino UNO:

In file included from C:\Daten\myrepository\Arduino\libraries\StreamLib\src/StreamLib.h:25:0,
                 from C:\Daten\myrepository\Arduino\HW_arduino\lcd_led_dht_server_client_ajax\lcd_led_dht_server_client_ajax.ino:50:
C:\Daten\myrepository\Arduino\libraries\StreamLib\src/ChunkedStreamReader.h: In member function 'virtual size_t ChunkedStreamReader::write(uint8_t)':
C:\Daten\myrepository\Arduino\libraries\StreamLib\src/ChunkedStreamReader.h:39:32: warning: unused parameter 'b' [-Wunused-parameter]
   virtual size_t write(uint8_t b) {
                                ^
In file included from C:\Daten\myrepository\Arduino\libraries\StreamLib\src/StreamLib.h:26:0,
                 from C:\Daten\myrepository\Arduino\HW_arduino\lcd_led_dht_server_client_ajax\lcd_led_dht_server_client_ajax.ino:50:
C:\Daten\myrepository\Arduino\libraries\StreamLib\src/StringReadStream.h: In member function 'virtual size_t StringReadStream::write(uint8_t)':
C:\Daten\myrepository\Arduino\libraries\StreamLib\src/StringReadStream.h:42:32: warning: unused parameter 'b' [-Wunused-parameter]
   virtual size_t write(uint8_t b) {

both might be fixable with a simple

(void)b; // avoid warning unused parameter

Software WDT with ESP8266 when sending large strings

Hello!

Many thanks for this awesome library!

I have to send a long string (>10 000 char) through my ENC28J60 with ESP8266. It is impossible due to calculation duration, the software WDT makes a reset.

I have already put a yield() inside :

size_t BufferedPrint::write(const uint8_t *buf, size_t length)
{ 
yield(); 
for (size_t...

Helped a lot but did not solved. Still crashing while writting.

How can it be improved?

Thanks in advance!

PS: my code is

const size_t BUFFER_SIZE = 128;
char html_buff[BUFFER_SIZE];
BufferedPrint message(client, html_buff, sizeof(html_buff));
message.print(F(HTML_STRING));

with HTML_STRING the 10Ko string.

BufferedPrint.cpp:51:18: error: 'class Print' has no member named 'availableForWrite'

some cores have the Arduino API older then 2017 and are missing Print::availbleForWrite function.

workaround:

int BufferedPrint::availableForWrite() {
//  int a = target.availableForWrite();
//  if (!a) // target doesn't report aFW or is really full
    return size - pos; // then return space left in our buffer
//  a = a - pos; // what will be left in target after our flush()
//  return a < 0 ? 0 : a;
}

FormattedPrint doesn't compile with Arduino SAMD core 1.8.x

/home/duro/eclipse/arduinoPlugin/libraries/StreamLib/1.0.2/src/FormattedPrint.cpp:56:3: error: 'cookie_io_functions_t' was not declared in this scope
   cookie_io_functions_t fncs;
   ^~~~~~~~~~~~~~~~~~~~~
/home/duro/eclipse/arduinoPlugin/libraries/StreamLib/1.0.2/src/FormattedPrint.cpp:57:3: error: 'fncs' was not declared in this scope
   fncs.write = adapterWrite;
   ^~~~
/home/duro/eclipse/arduinoPlugin/libraries/StreamLib/1.0.2/src/FormattedPrint.cpp:57:3: note: suggested alternative: 'fls'
   fncs.write = adapterWrite;
   ^~~~
   fls
/home/duro/eclipse/arduinoPlugin/libraries/StreamLib/1.0.2/src/FormattedPrint.cpp:59:10: error: 'fopencookie' was not declared in this scope
   return fopencookie(p, "w", fncs);

in stdio.h are added ifdefs which exclude 'cookie' section

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.