These are chat archives for esp8266/Arduino

5th
Nov 2017
Douglas Pearless
@DouglasPearless
Nov 05 2017 08:34
has anyone tried to convert a "standard" Arduino sketch to use the me-no-dev/ESPAsyncTCP libraries?
for example me-no-dev/ESPAsyncTCP#67
Me No Dev
@me-no-dev
Nov 05 2017 08:38
I have :D
Douglas Pearless
@DouglasPearless
Nov 05 2017 08:38
Ah Ha, I figured you of all possible people might have :-)
I like the look of the library and have been scratching my head after reading as many examples as I could find; would you have an example you could share?
Me No Dev
@me-no-dev
Nov 05 2017 08:40
what do you want to achieve?
Douglas Pearless
@DouglasPearless
Nov 05 2017 08:41
I want to convert my sketch to use your async buffering library to solve a problem where the block TCP libraries that come with ESP8266/Arduino are causing me to lose characters; this is to add a telnet WiFi connection to Smoothie and other 3D printers / lasercutters
(I have spend a lot of hours tracing the problem down to the TCP end of the equation)
brutzler
@brutzler
Nov 05 2017 08:42
let me hook up:
what is the advantage of a async-TCP-connection?
Me No Dev
@me-no-dev
Nov 05 2017 08:42
why buffering?
@brutzler it does not hold the loop
@DouglasPearless there is an example for Async telnet in github
i think...
if you are going to push the telnet to the serial, you do not need to buffer
Douglas Pearless
@DouglasPearless
Nov 05 2017 08:44
I have LaserWeb send data to the Smoothie via a telnet connection via an ESP8266; the replies lose characters etc. By logging to Serial1 I can see the data flowing to the Smoothie UART and back to the ESP8266 but sometimes not all the characters get back over WiFi to LaswerWeb
I did not see an Async telnet example, I will check again, just a moment
Me No Dev
@me-no-dev
Nov 05 2017 08:47
not there... let me look
Douglas Pearless
@DouglasPearless
Nov 05 2017 08:47
ok, thanks
here is an old example you can look at
Douglas Pearless
@DouglasPearless
Nov 05 2017 08:49
cool
Is that a complete sketch as I get "'AsyncClient' has not been declared"
Me No Dev
@me-no-dev
Nov 05 2017 08:52
missing the include it seems
Douglas Pearless
@DouglasPearless
Nov 05 2017 08:52
:-)
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:00
I added the following includes and it now compiles:

include <ESPAsyncTCPbuffer.h>

include <ESP8266WiFi.h>

include <ArduinoOTA.h>

Me No Dev
@me-no-dev
Nov 05 2017 09:00
you need ESPAsyncTCP not the buffer
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:00
oops, that wasn't supposed to be so big, I guess the "#" is some kind of markup
Me No Dev
@me-no-dev
Nov 05 2017 09:01
yeah...
read on github markup :)
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:01

Interesting, if I remove that include I get:
AsyncTelnetServer:28: error: 'AsyncClient' has not been declared
void onPoll(void obj, AsyncClient c){

and a lot of other erro

Me No Dev
@me-no-dev
Nov 05 2017 09:03
#include <ESPAsyncTCP.h>
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:03
your sketch requires either:
ESPAsyncTCP.h
or
ESPAsyncTCPbuffer.h
in order to compile
Me No Dev
@me-no-dev
Nov 05 2017 09:03
do not remove it... use the non-buffer one
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:03
Ah, ok
now using the non buffer one; going to try in a minute; compiling and uploading now :-)
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:13
A couple of quick questions, where does os_printf send its output, can I get it to write to Serial1 ?
or does that actually go to the UART0 which I think it does
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:32
I will need to sit down and better understand how this works as I seen to be getting strange data back; it seems to be chopping lines (Strings) up ie. send "X250.80 S0.1516"
expecting back an
"ok"
but Smoothie replies:
"error: unsupported command - X:124"
so it appears something is going wrong send data across the ESP to Smoothies UART :-(
Me No Dev
@me-no-dev
Nov 05 2017 09:33
well check the code :) probably sending new lines somwhere
I gave you an example, not a eworking code for your need
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:33
I am reading the code right now, I appreciate the example, certainly something to work on :-)
Me No Dev
@me-no-dev
Nov 05 2017 09:35
so this part actually sets os_printf:
void _u0_putc(char c){
  while(((U0S >> USTXC) & 0x7F) == 0x7F);
  U0F = c;
}
void setup(){
  Serial.begin(115200);
  ets_install_putc1((void *) &_u0_putc);
  system_set_os_print(1);
}
void _u1_putc(char c){
  while(((U1S >> USTXC) & 0x7F) == 0x7F);
  U1F = c;
}
void setup(){
  Serial1.begin(115200);
  ets_install_putc1((void *) &_u1_putc);
  system_set_os_print(1);
}
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:36
Ah Ha, Serial is on UART0 and the 1 = UART1 I assume? and there
Me No Dev
@me-no-dev
Nov 05 2017 09:36
here it is for serial1
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:37
great, is it set at 115200 as well or that odd 74800 rate?
Me No Dev
@me-no-dev
Nov 05 2017 09:37
read the code again ;) it's calling Serial.begin
Douglas Pearless
@DouglasPearless
Nov 05 2017 09:38
oops, staring me in the face, clearly not enough coffee today
Clemens Kirchgatterer
@everslick
Nov 05 2017 09:43
I tried the AsyncWebserver approx. a year ago, but i ran into out of heap issues back then. are the requirements on RAM still the same?
because you mentioned buffered/non buffered implementation.
Me No Dev
@me-no-dev
Nov 05 2017 09:46
@everslick if you are handling 5 connections at the same time, there are resources allocated for all 5 :)
Clemens Kirchgatterer
@everslick
Nov 05 2017 09:52
thats kind of to be expected. :-D
but i have no control over how many connections the browser opens to fetch different resources from the server, so it is hard to predict what happens.
Me No Dev
@me-no-dev
Nov 05 2017 09:54
if you are low on RAM and can not afford to handle multiple connections, then by all means you should use the sync server and make sure you handle only one
actually you do have ;)
Clemens Kirchgatterer
@everslick
Nov 05 2017 09:54
yes?
Me No Dev
@me-no-dev
Nov 05 2017 09:54
it depends on your design
Clemens Kirchgatterer
@everslick
Nov 05 2017 09:54
yeah
Me No Dev
@me-no-dev
Nov 05 2017 09:54
I have successfuly used javascript to fetch resources one by one (even AJAX)
Clemens Kirchgatterer
@everslick
Nov 05 2017 09:55
that could be an idea
Me No Dev
@me-no-dev
Nov 05 2017 09:55
the days before Async :D
let me see if I can dig up the code
Clemens Kirchgatterer
@everslick
Nov 05 2017 09:56
that would be very kind of you, sir.
like this?
Me No Dev
@me-no-dev
Nov 05 2017 10:12
@everslick i sent it to you in private :D
brutzler
@brutzler
Nov 05 2017 10:17

Hi,
for remote debugging I sometimes use an "debug-ESP" and transfer everything what is coming from my "main-ESP" into the serial interface via UDP broadcast.

  if (stringComplete) {
    UDP.beginPacket("192.168.1.255", 514);        // Broadcast on Port 514
    UDP.write(inputString.c_str());
    UDP.endPacket();
    inputString = "";
    stringComplete = false;
  }

A terminal program (YAT) on the PC is receiving the debug messages.
Just thinking, why this can not be done from the "main-ESP" itself...
Do you think, I can gain any problems with this way? run out of numbers of connections/sockets?

Clemens Kirchgatterer
@everslick
Nov 05 2017 10:19
i use this all the time.
just try it
keep in mind, that if you send too often, the ESP will just drop some packets, without any error.
brutzler
@brutzler
Nov 05 2017 10:24

any hint how to make this easier?
normally I use for debug on serial something like this:

#define DEBUG Serial1
DEBUG << String(Date)<< "  " << String(Time) <<  endl

Can I make somehow a "#define DEBUG UDP". What do I need for this?

Or is there already something part of the ESP-kernel?
Me No Dev
@me-no-dev
Nov 05 2017 10:28
might not get the result you expect :D
that above will probably send 3 packets
Clemens Kirchgatterer
@everslick
Nov 05 2017 10:44
clean way would probably be to implement a class that inherits from Stream, and sends everything via UDP.
brutzler
@brutzler
Nov 05 2017 10:47
I agree. But developing this, is beyond my abilities :-(
How do you use UDP-Debug in your sketches?
Clemens Kirchgatterer
@everslick
Nov 05 2017 11:46
with big and complicated code. :-D
brutzler
@brutzler
Nov 05 2017 13:02
@everslick is this neccessary?
Develo
@devyte
Nov 05 2017 14:33
@me-no-dev will you be updating the ESPAsyncUDP lib soon? Sorry to bug you Bbo
About
About it*
Me No Dev
@me-no-dev
Nov 05 2017 14:34
sure :)
Develo
@devyte
Nov 05 2017 14:36
Thanks! I tried to give it a shot, but lost sanity quickly. There's too much confusion in the changes from lwip 1.4 to lwip 2 wrt ip addresses with all the typedefs
After we
(Sorry, daughter is trolling me for ny phone)
Me No Dev
@me-no-dev
Nov 05 2017 14:39
hahahahah
Develo
@devyte
Nov 05 2017 14:40
After we discussed the async udp lib some time ago, I've been keeping an eye out for libs that work asynchronously and use udpcontext, and I think they really would improve with the espasyncudp lib
Me No Dev
@me-no-dev
Nov 05 2017 14:42
AsynsUDP is probably the easiest way to build UDP services :)
it will be a part of ESP32 Arduino ;)
at least for me :D
Develo
@devyte
Nov 05 2017 15:09
After debugging my daughter, turns out she just needed some milk :smile:
Me No Dev
@me-no-dev
Nov 05 2017 15:12
hahahahahahaha
hack a milk bottle on her head ;)
maybe attach ESP to MQTT when she uses it
Develo
@devyte
Nov 05 2017 15:14
I was thinking milk-on-demand, but I suspect that would break the whole diaper solution
The esp32 firmware is built on freeRTOS, right?
Me No Dev
@me-no-dev
Nov 05 2017 15:17
yup :)
Develo
@devyte
Nov 05 2017 15:18
Is the whole task api exposed to the user?
Me No Dev
@me-no-dev
Nov 05 2017 15:19
yup
yes it is.
Me No Dev
@me-no-dev
Nov 05 2017 15:19
well... honestly there are some missleading things in this video\
Victor Tseng
@Palatis
Nov 05 2017 15:20
at least it's an entry point for noobs
Me No Dev
@me-no-dev
Nov 05 2017 15:20
that it is :)
Develo
@devyte
Nov 05 2017 15:20
thx for the video
Victor Tseng
@Palatis
Nov 05 2017 15:21
the create task / pin task stuff is correct
Me No Dev
@me-no-dev
Nov 05 2017 15:21
it's all generally correct
could have given a better example of dual core operations though
Victor Tseng
@Palatis
Nov 05 2017 15:22
like dual core lzma?
XDX
Develo
@devyte
Nov 05 2017 15:50
Nah, I know about realtime OSs, implemented a tiny one myself way back. It's clear enough to me: you can bring up tasks, assign them to a specific core, and there are semaphores available. And the sketch is a task by itself, probably with higher priority
Me No Dev
@me-no-dev
Nov 05 2017 15:52
actually it's idle priority and the only task running on core1
Develo
@devyte
Nov 05 2017 15:52
Ah, ok
Me No Dev
@me-no-dev
Nov 05 2017 15:53
so if you stick to regular Arduino programming, you should get as close as possible to what you would expect
Develo
@devyte
Nov 05 2017 16:10
Lol you already got an issue opened in your ESPAsyncUDP repo about lwip2
I didn't want to do that because the whole lwip2 thing is supposed to be experimental