Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommandProcessing with WebSocket #2665

Closed
sreggy opened this issue Sep 18, 2023 · 17 comments
Closed

CommandProcessing with WebSocket #2665

sreggy opened this issue Sep 18, 2023 · 17 comments

Comments

@sreggy
Copy link

sreggy commented Sep 18, 2023

Hi all,
I've tryed CommandProcessing sample for manage command handler using websocket.

It works fine with serial and telnet but I'm not able to use it with websocket. It's like the command handler is not attached to websocket interface.

Can anyone help me?

Thanks in advance
Regards
Stefano

@slaff
Copy link
Contributor

slaff commented Dec 6, 2023

@sreggy I am working on a PR #2687 that will make it possible to use CommandProcessor for any text line interface.

@sreggy
Copy link
Author

sreggy commented Dec 12, 2023

Thanks a lot @slaff.
As soon as something is usable, available to test it.

Just another question, is this text line interface useful also using MQTT?

Thanks again,
Regards
Stefano

@slaff
Copy link
Contributor

slaff commented Dec 12, 2023

Just another question, is this text line interface useful also using MQTT?

Yes. You can take the MqttClient_Hello sample as a starting point and modify the onMessageReceived callback from app/application.cpp to process the messages via CommandHandler. Something like:

#include <CommandProcessing/Utils.h>

CommandProcessing::Handler commandHandler;

// Callback for messages, arrived from MQTT server
int onMessageReceived(MqttClient& client, mqtt_message_t* message)
{
	String output = commandHandler.processNow(reinterpret_cast<const char*>(message->publish.content.data), message->publish.content.length);
	if(output.length() > 0) {
		client.publish(MqttBuffer(message->publish.topic_name), output);
	}

	return 0;
}

Make sure also to add the dependency on CommandProcessor. This can be done by adding the following line to the application component.mk file.

COMPONENT_DEPENDS += CommandProcessing

@slaff
Copy link
Contributor

slaff commented Dec 12, 2023

As soon as something is usable

It is already merged in the develop branch and you can test it right away.

@sreggy
Copy link
Author

sreggy commented Dec 12, 2023

Hi @slaff I did some test using the provided sample for Telnet but I'm not able to have success.
I'm able to connect to the telnet session, but if I send a command, no output on Telenet session.
Out seems to be redirect on Serial with the following error message 154552374 Cannot use this method when output stream is set.

here Telnet session

❯ telnet 192.168.0.173
Trying 192.168.0.173...
Connected to testone.saruman.
Escape character is '^]'.
help
help

here Serial output

249433837 Cannot use this method when output stream is set
% !"'252789766 Cannot use this method when output stream is set
helpCommand not found, cmd = '%'
Sming>
258061171 Cannot use this method when output stream is set
helpCommands available are :
status | system | Displays System Information
echo | system | Displays command entered
help | system | Displays all available commands
debugon | system | Set Serial debug on
debugoff | system | Set Serial debug off
command | system | Use verbose/silent/prompt as command options
example | Application | Example Command
Sming>

Any suggestion?
Thanks in advance.
Regards
Stefano

@slaff
Copy link
Contributor

slaff commented Dec 13, 2023

Any suggestion?

Yes, commend line 58 in app/application.cpp TelnetServer sample:

	commandHandler.setVerbose(true);
//	CommandProcessing::enable(commandHandler, Serial);

	WifiStation.enable(true);

And recompile the example.

@slaff
Copy link
Contributor

slaff commented Dec 13, 2023

And something more. When you connect use the following command:

❯ telnet 192.168.0.173 23

Notice the port number after the IP. Without it your telnet client will switch to telnet protocol and will send an initial telnet packet which this simple sample does not support.

@sreggy
Copy link
Author

sreggy commented Dec 13, 2023

Any suggestion?

Yes, commend line 58 in app/application.cpp TelnetServer sample:

	commandHandler.setVerbose(true);
//	CommandProcessing::enable(commandHandler, Serial);

	WifiStation.enable(true);

And recompile the example.

Thanks a lot @slaff .
Doing this, is CommandProcessing also working on Serial or I need register a different commandHandler?

thanks again
regards

Steafano

@slaff
Copy link
Contributor

slaff commented Dec 13, 2023

is CommandProcessing also working on Serial

Only on the TelnetServer. For Serial you need to create a new commandHandler.

@sreggy
Copy link
Author

sreggy commented Dec 14, 2023

Hi @slaff,
well using two commandHaldler I was able to use CommandProcessing from both Serial and from text line interface like Telnet and MQTT.

Some trouble on Websocket because receive a stacktrace on httpServer access for both http and ws with a simple http://192.168.0.174 i receive (using the Sming/samples/HttpServer_WebSockets sample):

python3 -m serial.tools.miniterm --raw --encoding ascii --rts 0 --dtr 0 /dev/cu.usbserial-0001 916000
--- forcing DTR inactive
--- forcing RTS inactive
--- Miniterm on /dev/cu.usbserial-0001  916000,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
��rf[113] : 00
rf[114] : 01

SDK ver: 3.0.3(8427744) compiled @ Mar 19 2020 18:11:05
phy ver: 1156_0, pp ver: 10.2

134888 Station configuration is: ILUVATAR
mode : sta(c4:5b:be:49:55:3a)
add if0
179681 mode: 0 -> 3

scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt

connected with ILUVATAR, channel 1
dhcp client start...
298310 connect to ssid ILUVATAR, channel 1

ip:192.168.0.174,mask:255.255.255.0,gw:192.168.0.1
1161831 ip:192.168.0.174,mask:255.255.255.0,gw:192.168.0.1

1162188 TCP 3ffef270 +connection
1162450 '/' registered
1162689 '*' registered

=== WEB SERVER STARTED ===
192.168.0.174
==========================

5433120 onAccept, tcp: 3fff18d8, state: 0 K=0, Free heap size=42152
5433428 TCP 3fff1c68 +connection
5433755 TCP 3fff1c68 timeout updating: 70 -> 2
5433947 Opening connection. Total connections: 1
5434135 TcpServer onClient: 192.168.0.190

5435155 onAccept, tcp: 3fff1b20, state: 0 K=1, Free heap size=41448
5435404 TCP 3fff1f40 +connection
5435814 TCP 3fff1f40 timeout updating: 70 -> 2
5436292 Opening connection. Total connections: 2
5436794 TcpServer onClient: 192.168.0.190

5443808 The headers are complete
5450267 attached file: 'index.html' (1639 bytes) #0x3FFF1440
5451424 MemoryDataStream::realloc 0 -> 17
5451587 Sending stream. Bytes to send: 17
5451999 MemoryDataStream::realloc 17 -> 170
5452123 Sending stream. Bytes to send: 42
5452285 Sending stream. Bytes to send: 70
5452558 Sending stream. Bytes to send: 94
5452999 Sending stream. Bytes to send: 120
5453467 Sending stream. Bytes to send: 122
5453960 TCP 3fff1c68 onReadyToSendData: 1
5454629 TCP 3fff1c68 Written: 122, Available: 2780, isFinished: 0, PushCount: 1
5455285 TcpClient stream finished
5457134 TCP 3fff1c68 Written: 1012, Available: 2658, isFinished: 0, PushCount: 1
5458160 TCP 3fff1c68 Written: 659, Available: 1646, isFinished: 0, PushCount: 2
5458493 TcpClient stream finished


***** Fatal exception 28 (LOAD_PROHIBITED)
pc=0x4000df7c sp=0x3ffffbe0 excvaddr=0x08800000
ps=0x00000030 sar=0x0000001e vpri=0x6e65696c
r00: 0x40237474=1076065396 r01: 0x3ffffbe0=1073740768 r02: 0x3ffffc20=1073740832
r03: 0x08800000= 142606336 r04: 0x00000008=         8 r05: 0x3ffffc20=1073740832
r06: 0x3fff1bd0=1073683408 r07: 0x00000000=         0 r08: 0x00000003=         3
r09: 0x3ffefb04=1073675012 r10: 0x00000008=         8 r11: 0x0000006c=       108
r12: 0x3ffffc20=1073740832 r13: 0x00000005=         5 r14: 0x08800000= 142606336
r15: 0x3ffec5ea=1073661418

Stack dump:
To decode the stack dump call from command line:
   make decode-stacktrace
and copy & paste the text enclosed in '===='.

================================================================
3ffffbe0:  4024ad70 00000005 3ffffc20 40236ac0
3ffffbf0:  3fff22a0 00000003 3fff1c68 40236b06
3ffffc00:  4024ad84 3ffffc10 3fff2218 4023558c
3ffffc10:  00010000 00000003 3fff1c68 40249894
3ffffc20:  00000000 00000000 80000000 40250968
3ffffc30:  00010000 00000003 3fff1c68 402484ec
3ffffc40:  54207525 6c437063 746e6569 72747320
3ffffc50:  206d6165 696e6966 64656873 00000a0d
3ffffc60:  00010000 00000003 3fff1c68 40248720
3ffffc70:  00000000 00000000 00000000 00000001
3ffffc80:  00010000 00000003 3fff1c68 402498c8
3ffffc90:  64656873 00000a0d 3fff1c68 40250968
3ffffca0:  00010000 00000001 3fff1c68 402484ec
3ffffcb0:  54207525 6c437063 746e6569 72747320
3ffffcc0:  206d6165 696e6966 64656873 00000a0d
3ffffcd0:  3fff1e24 00000001 3fff1c68 40248720
3ffffce0:  4010119b 00000000 3fff1da0 3ffec5ea
3ffffcf0:  00010000 00000001 3fff1c68 402498c8
3ffffd00:  00000000 3fff14a4 3fff1d2c 4024a5a8
3ffffd10:  00010000 00000000 3fff1c68 40250a71
3ffffd20:  00010000 00000000 3fff1c68 40248f55
3ffffd30:  63206572 ffffffff 3fff1c68 40250b94
3ffffd40:  0000000d 00004808 3fff1ce0 4024d4c0
3ffffd50:  3ffec402 000001e9 40233b00 00000000
3ffffd60:  00000000 00000000 00000000 00000000
3ffffd70:  00000000 3ffec5eb 00000000 00014000
3ffffd80:  00000001 0000d008 00000004 402369ed
3ffffd90:  0052f57a 3ffec5e7 00000000 40237fe1
3ffffda0:  3ffffdc0 3ffffdb0 00000004 000001e9
3ffffdb0:  00000001 7f000000 3fff1c68 4024a321
3ffffdc0:  3fff1ce0 3ffffdcd 39312e30 40240030
3ffffdd0:  4010119b 3ffffe60 3ffef270 00000000
3ffffde0:  3fff13f8 3fff13f8 3fff1c68 40250bd4
3ffffdf0:  00000005 00000000 00000020 402486a2
3ffffe00:  000001e9 4010409b 3ffed610 be00a8c0
3ffffe10:  4010539f 3ffed610 3ffef270 40246ff4
3ffffe20:  00007fff 00530040 3ffedd08 40105578
3ffffe30:  3ffea43c 00000000 00000000 3ffec402
3ffffe40:  3fff1cc8 00530040 40105a42 00000100
3ffffe50:  3ffea43c 00000000 7fffffff 00000000
3ffffe60:  3fff1c68 3fff13f8 00000000 40247f28
3ffffe70:  4021dcca 3ffea43c 00530040 3ffea400
3ffffe80:  00000000 2c9f0300 4000050c 00000000
3ffffe90:  3fffc278 40105754 3fffc200 00000022
3ffffea0:  4000000a 3fff13f8 3fffc250 4000050c
3ffffeb0:  3ffeecac 3ffeeca8 000001fd 3fff18d8
3ffffec0:  3ffeecf0 3fff18d8 3fff13f8 40247f98
3ffffed0:  3ffeecf0 3ffeece0 3ffeecdc 4021d000
3ffffee0:  ae00a8c0 000001e9 00001850 00000018
3ffffef0:  00000000 3fff13e8 00000184 4021de48
3fffff00:  3ffe0000 00000024 00000008 3ffec3da
3fffff10:  3fff13f8 3ffeeca8 3ffeecb0 4021a8d1
3fffff20:  00000014 00000000 a4603a55 3fff1318
3fffff30:  00000000 01961676 4022c10f 3ffec3cc
3fffff40:  3fffdc80 3fff13f8 3fff1318 4021a431
3fffff50:  4022c178 3ffe9994 3ffe9070 0053012a
3fffff60:  40100b3d 0197b054 00000002 4022cbf3
3fffff70:  40214634 3ffe9044 3ffe9070 0053012a
3fffff80:  4021465a 3fffdab0 00000000 3fff13a0
3fffff90:  3fffdc80 00000000 3fff13f8 40218fdf
3fffffa0:  40000f49 3fffdab0 01000081 40000f49

================================================================
To decode the stack dump call from command line:
   make decode-stacktrace
and copy & paste the text enclosed in '===='.


***** Software Watchdog Reset

Stack dump:
To decode the stack dump call from command line:
   make decode-stacktrace
and copy & paste the text enclosed in '===='.

================================================================
3ffffac0:  3ffffae0 00000023 6e6f206e 3ffec5ea
3ffffad0:  00010000 00000003 3ffef418 400005e1
3ffffae0:  4000df7c 00000030 0000001e 6e65696c
3ffffaf0:  40237474 3ffffc20 08800000 00000008
3ffffb00:  3ffffc20 3fff1bd0 00000000 00000003
3ffffb10:  3ffefb04 00000008 0000006c 3ffffc20
3ffffb20:  00000005 08800000 3ffec5ea 0000001c
3ffffb30:  2f2f2020 73626577 656b636f 6c632e74
3ffffb40:  2865736f 200a3b29 0a0a7d20 75662020
3ffffb50:  3ffefd78 6f206e6f 7272456e 6528726f
3ffffb60:  3ffefa68 00000001 3ffefb04 40240b59
3ffffb70:  3ffefa68 00000000 00000001 4023c6d1
3ffffb80:  79747320 223d656c 6f6c6f63 3ffec5ea
3ffffb90:  4010119b 3fff1440 00000003 40238354
3ffffba0:  4010119b 3fff1be0 3fff1bf0 402353af
3ffffbb0:  40235b0e 3fff2330 00000003 402353ce
3ffffbc0:  4010119b 3fff1be0 00000003 40235b60
3ffffbd0:  4024ad84 00000003 3fff1be0 40235b9b
3ffffbe0:  4024ad70 00000005 3ffffc20 40236ac0
3ffffbf0:  3fff22a0 00000003 3fff1c68 40236b06
3ffffc00:  4024ad84 3ffffc10 3fff2218 4023558c
3ffffc10:  00010000 00000003 3fff1c68 40249894
3ffffc20:  00000000 00000000 80000000 40250968
3ffffc30:  00010000 00000003 3fff1c68 402484ec
3ffffc40:  54207525 6c437063 746e6569 72747320
3ffffc50:  206d6165 696e6966 64656873 00000a0d
3ffffc60:  00010000 00000003 3fff1c68 40248720
3ffffc70:  00000000 00000000 00000000 00000001
3ffffc80:  00010000 00000003 3fff1c68 402498c8
3ffffc90:  64656873 00000a0d 3fff1c68 40250968
3ffffca0:  00010000 00000001 3fff1c68 402484ec
3ffffcb0:  54207525 6c437063 746e6569 72747320
3ffffcc0:  206d6165 696e6966 64656873 00000a0d
3ffffcd0:  3fff1e24 00000001 3fff1c68 40248720
3ffffce0:  4010119b 00000000 3fff1da0 3ffec5ea
3ffffcf0:  00010000 00000001 3fff1c68 402498c8
3ffffd00:  00000000 3fff14a4 3fff1d2c 4024a5a8
3ffffd10:  00010000 00000000 3fff1c68 40250a71
3ffffd20:  00010000 00000000 3fff1c68 40248f55
3ffffd30:  63206572 ffffffff 3fff1c68 40250b94
3ffffd40:  0000000d 00004808 3fff1ce0 4024d4c0
3ffffd50:  3ffec402 000001e9 40233b00 00000000
3ffffd60:  00000000 00000000 00000000 00000000
3ffffd70:  00000000 3ffec5eb 00000000 00014000
3ffffd80:  00000001 0000d008 00000004 402369ed
3ffffd90:  0052f57a 3ffec5e7 00000000 40237fe1
3ffffda0:  3ffffdc0 3ffffdb0 00000004 000001e9
3ffffdb0:  00000001 7f000000 3fff1c68 4024a321
3ffffdc0:  3fff1ce0 3ffffdcd 39312e30 40240030
3ffffdd0:  4010119b 3ffffe60 3ffef270 00000000
3ffffde0:  3fff13f8 3fff13f8 3fff1c68 40250bd4
3ffffdf0:  00000005 00000000 00000020 402486a2
3ffffe00:  000001e9 4010409b 3ffed610 be00a8c0
3ffffe10:  4010539f 3ffed610 3ffef270 40246ff4
3ffffe20:  00007fff 00530040 3ffedd08 40105578
3ffffe30:  3ffea43c 00000000 00000000 3ffec402
3ffffe40:  3fff1cc8 00530040 40105a42 00000100
3ffffe50:  3ffea43c 00000000 7fffffff 00000000
3ffffe60:  3fff1c68 3fff13f8 00000000 40247f28
3ffffe70:  4021dcca 3ffea43c 00530040 3ffea400
3ffffe80:  00000000 2c9f0300 4000050c 00000000
3ffffe90:  3fffc278 40105754 3fffc200 00000022
3ffffea0:  4000000a 3fff13f8 3fffc250 4000050c
3ffffeb0:  3ffeecac 3ffeeca8 000001fd 3fff18d8
3ffffec0:  3ffeecf0 3fff18d8 3fff13f8 40247f98
3ffffed0:  3ffeecf0 3ffeece0 3ffeecdc 4021d000
3ffffee0:  ae00a8c0 000001e9 00001850 00000018
3ffffef0:  00000000 3fff13e8 00000184 4021de48
3fffff00:  3ffe0000 00000024 00000008 3ffec3da
3fffff10:  3fff13f8 3ffeeca8 3ffeecb0 4021a8d1
3fffff20:  00000014 00000000 a4603a55 3fff1318
3fffff30:  00000000 01961676 4022c10f 3ffec3cc
3fffff40:  3fffdc80 3fff13f8 3fff1318 4021a431
3fffff50:  4022c178 3ffe9994 3ffe9070 0053012a
3fffff60:  40100b3d 0197b054 00000002 4022cbf3
3fffff70:  40214634 3ffe9044 3ffe9070 0053012a
3fffff80:  4021465a 3fffdab0 00000000 3fff13a0
3fffff90:  3fffdc80 00000000 3fff13f8 40218fdf
3fffffa0:  40000f49 3fffdab0 01000081 40000f49

================================================================
To decode the stack dump call from command line:
   make decode-stacktrace
and copy & paste the text enclosed in '===='.
�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������rf[113] : 00
rf[114] : 01

SDK ver: 3.0.3(8427744) compiled @ Mar 19 2020 18:11:05
phy ver: 1156_0, pp ver: 10.2

133617 Station configuration is: ILUVATAR
mode : sta(c4:5b:be:49:55:3a)
add if0
201178 mode: 0 -> 3

scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt

connected with ILUVATAR, channel 1
dhcp client start...
306592 connect to ssid ILUVATAR, channel 1

ip:192.168.0.174,mask:255.255.255.0,gw:192.168.0.1
1160559 ip:192.168.0.174,mask:255.255.255.0,gw:192.168.0.1

1160917 TCP 3ffef270 +connection
1161183 '/' registered
1161427 '*' registered

=== WEB SERVER STARTED ===
192.168.0.174
==========================

pm open,type:2 0
ip:192.168.0.174,mask:255.255.255.0,gw:192.168.0.1

any suggestion?

Thanks in advance
regards
Stefano

@slaff
Copy link
Contributor

slaff commented Dec 15, 2023

@sreggy do me a favour and add more information to this bug report.

  • First what is the (micro-controller) architecture that you are using? Is it Esp32 or Esp8266 ?
  • Second: Run the following command from the root folder of the project:
make decode-stacktrace

And paste the text enclosed in '===='. Exactly as instructed above.

  • Third: In order to be able to test it properly the message that you send via your Websocket client must contain new line at the end. If your websocket client is not adding a new line at the end of a message then you have to add it (by pressing Enter and then clicking on submit or whatever button you have)

Meanwhile I will run the stock HttpServer_WebSockets on Host and see if I can reproduce something.

@sreggy
Copy link
Author

sreggy commented Dec 15, 2023

Hi @slaff , inline the info

  • First what is the (micro-controller) architecture that you are using? Is it Esp32 or Esp8266 ?

Esp8266

  • Second: Run the following command from the root folder of the project:
make decode-stacktrace

And paste the text enclosed in '===='. Exactly as instructed above.

I did it, but unfortunatly I'm not able to well analyze the output, no problem to paste it in this thread, let me to know ...

  • Third: In order to be able to test it properly the message that you send via your Websocket client must contain new line at the end. If your websocket client is not adding a new line at the end of a message then you have to add it (by pressing Enter and then clicking on submit or whatever button you have)

Yes, i've added it. On Mqtt it's working fine ...

Meanwhile I will run the stock HttpServer_WebSockets on Host and see if I can reproduce something.

Thanks again
Regards
Stefano

@slaff
Copy link
Contributor

slaff commented Dec 15, 2023

no problem to paste it in this thread, let me to know ...

Yes, please do so.

@sreggy
Copy link
Author

sreggy commented Dec 15, 2023

Hi @slaff

I've tried to remove the WebSocker, leaving only the loading of the index.html

following the decode-stacktrace when with the browser i try to connect to http://192.168.0.174/

in serial log:

48694694 onAccept, tcp: 3fff3ce8, state: 0 K=0, Free heap size=33192
48695047 TCP 3fff3e58 +connection
48695421 TCP 3fff3e58 timeout updating: 70 -> 2
48697282 Opening connection. Total connections: 1
48701616 TcpServer onClient: 192.168.0.190

48708416 The headers are complete
HomePage access
48738601 attached file: 'index.html' (1639 bytes) #0x3FFF4268
48739909 MemoryDataStream::realloc 0 -> 17
48740105 Sending stream. Bytes to send: 17
48745501 MemoryDataStream::realloc 17 -> 170
48745659 Sending stream. Bytes to send: 42
48748825 Sending stream. Bytes to send: 70
48752641 Sending stream. Bytes to send: 94
48756414 Sending stream. Bytes to send: 120
48760316 Sending stream. Bytes to send: 157
48764181 Sending stream. Bytes to send: 159
48768121 TCP 3fff3e58 onReadyToSendData: 1
48772153 TCP 3fff3e58 Written: 159, Available: 2780, isFinished: 0, PushCount: 1
48779053 TcpClient stream finished
48783655 TCP 3fff3e58 Written: 1012, Available: 2621, isFinished: 0, PushCount: 1
48789926 TCP 3fff3e58 Written: 659, Available: 1609, isFinished: 0, PushCount: 2
48796453 TcpClient stream finished


***** Fatal exception 28 (LOAD_PROHIBITED)
pc=0x4000df7c sp=0x3ffffbe0 excvaddr=0x08800000
ps=0x00000030 sar=0x00000018 vpri=0x65696c43
r00: 0x40241080=1076105344 r01: 0x3ffffbe0=1073740768 r02: 0x3ffffc20=1073740832 
r03: 0x08800000= 142606336 r04: 0x00000008=         8 r05: 0x3ffffc20=1073740832 
r06: 0x3fff4258=1073693272 r07: 0x00000000=         0 r08: 0x00000003=         3 
r09: 0x00000050=        80 r10: 0x00000008=         8 r11: 0x00000003=         3 
r12: 0x3ffffc20=1073740832 r13: 0x00000005=         5 r14: 0x08800000= 142606336 
r15: 0x3ffeafa9=1073655721 

Stack dump:
To decode the stack dump call from command line:
   make decode-stacktrace
and copy & paste the text enclosed in '===='.

================================================================

then with decode-stacktrace

❯ make decode-stacktrace

ezri: Invoking 'decode-stacktrace' for Esp8266 (debug) architecture
Decode stack trace: Paste stack trace here
/opt/homebrew/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py:1010: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
  self.stdin = io.open(p2cwrite, 'wb', bufsize)

================================================================
3ffffd90:  4025adac 00000005 3ffffdd0 40240498  
3ffffda0:  3fff44d8 00000003 3fff40c8 402404de  
3ffffdb0:  4025adc0 3ffffdc0 3fff4460 40236958  
3ffffdc0:  3ffef7b0 00000003 3fff40c80x4025adac: operator delete[](void*) at ??:?
0x40240498: String::setlen(unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.h:870
 (inlined by) String::copy(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.cpp:263
 (inlined by) String::copy(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.cpp:255
0x402404de: String::setString(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.cpp:128
0x4025adc0: operator delete(void*, unsigned int) at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/heap/alloc.cpp:47
 40256ebc  
3ffffdd0:  00000000 00000000 80000000 40260a48  
3ffffde0:  3ffef7b0 00000002 3fff40c8 40x40236958: String::String(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.h:180
0x40256ebc: String::operator==(String const&) const at /Users/a020900/sming/Sming/Sming/Wiring/WString.h:456
 (inlined by) HttpServerConnection::onReadyToSendData(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/Http/HttpServerConnection.cpp:235
0x40260a48: TcpClient::freeStreams() at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:19
0253eb4  
3ffffdf0:  54207525 6c437063 746e6569 720x40253eb4: TcpClient::pushAsyncPart() at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:201
747320  
3ffffe00:  206d6165 696e6966 64656873 00000a0d  
3ffffe10:  74c8fc6c 00000002 3fff40c8 402540e8  
3ffffe20:  3ffffe60 3ffffe50 00000004 000000x402540e8: TcpClient::onReadyToSendData(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:174
030  
3ffffe30:  3ffef7b0 00000002 3fff40c8 40256ef0  
3ffffe40:  3ffffe60 3ffffe50 00000004 00002200x40256ef0: HttpServerConnection::onReadyToSendData(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/Http/HttpServerConnection.cpp:252
0  
3ffffe50:  3ffef7b0 0000056e 3fff40c8 40252e79  
3ffffe60:  00000002 00000000 4000050c 00000000 0x40252e79: TcpConnection::trySend(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.h:196
 
3ffffe70:  4021e47a 3fff4af0 3fff40c8 40252f26  0x4000050c: ?? ??:0

3ffffe80:  54207525 25205043 65732070 203a746e  
0x4021e47a: pbuf_free at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/pbuf.c:758
0x40252f26: TcpConnection::onSent(unsigned short) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:153
3ffffe90:  0a0d7525 00000000 3ffef7a4 4021dad5  
30x4021dad5: tcp_seg_free at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/tcp.c:1084
ffffea0:  40220000 3ffef7a0 3fff40c8 40254168  
3f0x40220000: dhcp_release at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/dhcp.c:1263
0x40254168: TcpClient::onSent(unsigned short) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:218
fffeb0:  3ffef76c 3ffef768 3fff40c8 40253988  
3ff0x40253988: TcpConnection::internalOnSent(unsigned short) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:501
ffec0:  00000000 3ffef7a0 3ffef79c 402539b1  
3fff0x402539b1: operator() at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:313
 (inlined by) _FUN at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:314
fed0:  3ffef7b0 3ffef7a0 3ffef79c 4021d769  
3ffff0x4021d769: tcp_input at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/tcp_in.c:370 (discriminator 1)
ee0:  ae00a8c0 00000000 00001050 00000010  
3ffffef0:  00000000 3fff3530 00000184 4021e5f8  
3fffff00x4021e5f8: pbuf_alloc at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/pbuf.c:389
0:  3ffe0000 00000024 00000008 3ffeaf46  
3fffff10:  3fff3540 3ffef768 3ffef770 4021b065  
3fffff20:0x4021b065: ip_input at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/ipv4/ip.c:559
  00000014 00000000 a4603a55 3fff2748  
3fffff30:  00000000 3fff3540 0000001c 3ffeaf38  
3fffff40:  3fffdc80 3fff3540 3fff2748 4021abc5  
3fffff50:  00x4021abc5: ethernet_input at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/netif/etharp.c:1379
000005e 3ffeefb0 00000000 00000023  
3fffff60:  0000001a 3fff3688 00000002 4022d5b3  
3fffff70:  3ff0x4022d5b3: ppRxPkt at /home/xcg/workspace/debug/esp8266_nonos_sdk_core_20180510/app/pp/pp.c:1086
ee080 3ffeaf10 3fffdcc0 3ffea6e0  
3fffff80:  4022d526 3ffee080 3fffdab0 3fff34f0  
3fffff90:  3fffd0x4022d526: ppRxPkt at /home/xcg/workspace/debug/esp8266_nonos_sdk_core_20180510/app/pp/pp.c:1086
c80 00000000 3fff3540 40219773  
3fffffa0:  40000f0x40219773: ets_snprintf at ??:?
49 3fffdab0 01000081 40000f49  

=================0x40000f49: ?? ??:0
0x40000f49: ?? ??:0
===============================================
================================================================
3ffffc70:  3ffffc90 00000024 3fff0428 3fff3e38  
3ffffc80:  3ffef7b0 00000002 3fff0428 400005e1  
3ffffc90:  4000df7c 00000030 000000180x400005e1: ?? ??:0
 65696c43  
3ffffca0:  402410b4 3ffffdd0 08800000 0x4000df7c: ?? ??:0
00000008  
3ffffcb0:  3ffffdd0 3fff43f0 00000000 00x402410b4: memcpy_aligned at /Users/a020900/sming/Sming/Sming/Wiring/FakePgmSpace.cpp:24
0000003  
3ffffcc0:  3fff17c4 00000008 00000003 3ffffdd0  
3ffffcd0:  00000005 08800000 3fff3e38 0000001c  
3ffffce0:  3ffef7b0 0000056e 3fff0428 4026034a  
3ffffcf0:  00000000 00000000 3ffea791 401000x4026034a: std::_Function_handler<unsigned int (char const*, unsigned int), std::_Bind<unsigned int (*(smg_uart_t*, std::_Placeholder<1>, std::_Placeholder<2>))(smg_uart_t*, void const*, unsigned int)> >::_M_invoke(std::_Any_data const&, char const*&&, unsigned int&&) at /Users/a020900/sming/esp-quick-toolchain/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/10.2.0/bits/std_function.h:293
595  
3ffffd00:  3fff1a98 00000022 3fff3108 3fff3e0x40100595: std::function<unsigned int (char const*, unsigned int)>::operator()(char const*, unsigned int) const at /Users/a020900/sming/esp-quick-toolchain/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/10.2.0/bits/std_function.h:623
38  
3ffffd10:  3fff1728 00000003 3fff17c4 4024c3ed  
3ffffd20:  3fff1728 00000000 00000003 40247f710x4024c3ed: SPIFFS_close at /Users/a020900/sming/Sming/Sming/Libraries/Spiffs/spiffs/src/spiffs_hydrogen.c:904 (discriminator 2)
  
3ffffd30:  63303466 65732038 203a746e 3fff3e38 0x40247f71: IFS::SPIFFS::FileSystem::close(short) at /Users/a020900/sming/Sming/Sming/Libraries/Spiffs/src/FileSystem.cpp:331
 
3ffffd40:  401013bf 3fff3c78 00000002 40242338  
3ffffd50:  401013bf 3fff3ef8 3fff3f08 4023a7ff  
0x401013bf: free at ??:?
0x40242338: IFS::FileStream::close() at /Users/a020900/sming/Sming/Sming/Core/Data/Stream/IFS/FileStream.cpp:63
0x401013bf: free at ??:?
3ffffd60:  40236a96 3fff45c8 00000002 4023a81e  
30x4023a7ff: FileStream::~FileStream() at /Users/a020900/sming/Sming/Sming/Core/Data/Stream/FileStream.h:20
ffffd70:  401013bf 3fff3ef8 00000002 4023ec3c  
3f0x40236a96: wiring_private::ObjectList<String>::~ObjectList() at /Users/a020900/sming/Sming/Sming/Wiring/WiringList.h:105
0x4023a81e: FileStream::~FileStream() at /Users/a020900/sming/Sming/Sming/Core/Data/Stream/FileStream.h:20
0x401013bf: free at ??:?
0x4023ec3c: TemplateStream::~TemplateStream() at /Users/a020900/sming/Sming/Sming/Core/Data/Stream/TemplateStream.h:70
fffd80:  4025adc0 00000002 3fff3ef8 4023ec77  
3ff0x4025adc0: operator delete(void*, unsigned int) at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/heap/alloc.cpp:47
0x4023ec77: TemplateFileStream::~TemplateFileStream() at /Users/a020900/sming/Sming/Sming/Core/Data/Stream/TemplateFileStream.h:20
ffd90:  4025adac 00000005 3ffffdd0 40240498  
3fff0x4025adac: operator delete[](void*) at ??:?
0x40240498: String::setlen(unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.h:870
 (inlined by) String::copy(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.cpp:263
 (inlined by) String::copy(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.cpp:255
fda0:  3fff44d8 00000003 3fff40c8 402404de  
3ffff0x402404de: String::setString(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.cpp:128
db0:  4025adc0 3ffffdc0 3fff4460 40236958  
3ffffd0x4025adc0: operator delete(void*, unsigned int) at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/heap/alloc.cpp:47
0x40236958: String::String(__FlashStringHelper const*, unsigned int) at /Users/a020900/sming/Sming/Sming/Wiring/WString.h:180
c0:  3ffef7b0 00000003 3fff40c8 40256ebc  
3ffffdd0x40256ebc: String::operator==(String const&) const at /Users/a020900/sming/Sming/Sming/Wiring/WString.h:456
 (inlined by) HttpServerConnection::onReadyToSendData(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/Http/HttpServerConnection.cpp:235
0:  00000000 00000000 80000000 40260a48  
3ffffde00x40260a48: TcpClient::freeStreams() at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:19
:  3ffef7b0 00000002 3fff40c8 40253eb4  
3ffffdf0:0x40253eb4: TcpClient::pushAsyncPart() at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:201
  54207525 6c437063 746e6569 72747320  
3ffffe00:  206d6165 696e6966 64656873 00000a0d  
3ffffe10:  74c8fc6c 00000002 3fff40c8 402540e8  
3ffffe20:  30x402540e8: TcpClient::onReadyToSendData(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:174
ffffe60 3ffffe50 00000004 00000030  
3ffffe30:  3ffef7b0 00000002 3fff40c8 40256ef0  
3ffffe40:  3ff0x40256ef0: HttpServerConnection::onReadyToSendData(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/Http/HttpServerConnection.cpp:252
ffe60 3ffffe50 00000004 00002200  
3ffffe50:  3ffef7b0 0000056e 3fff40c8 40252e79  
3ffffe60:  000000x40252e79: TcpConnection::trySend(TcpConnectionEvent) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.h:196
002 00000000 4000050c 00000000  
3ffffe70:  4021e40x4000050c: ?? ??:0
7a 3fff4af0 3fff40c8 40252f26  
3ffffe80:  54207520x4021e47a: pbuf_free at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/pbuf.c:758
0x40252f26: TcpConnection::onSent(unsigned short) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:153
5 25205043 65732070 203a746e  
3ffffe90:  0a0d7525 00000000 3ffef7a4 4021dad5  
3ffffea0:  40220000 0x4021dad5: tcp_seg_free at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/tcp.c:1084
3ffef7a0 3fff40c8 40254168  
3ffffeb0:  3ffef76c 30x40220000: dhcp_release at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/dhcp.c:1263
0x40254168: TcpClient::onSent(unsigned short) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpClient.cpp:218
ffef768 3fff40c8 40253988  
3ffffec0:  00000000 3f0x40253988: TcpConnection::internalOnSent(unsigned short) at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:501
fef7a0 3ffef79c 402539b1  
3ffffed0:  3ffef7b0 3ff0x402539b1: operator() at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:313
 (inlined by) _FUN at /Users/a020900/sming/Sming/Sming/Components/Network/src/Network/TcpConnection.cpp:314
ef7a0 3ffef79c 4021d769  
3ffffee0:  ae00a8c0 00000x4021d769: tcp_input at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/tcp_in.c:370 (discriminator 1)
0000 00001050 00000010  
3ffffef0:  00000000 3fff3530 00000184 4021e5f8  
3fffff00:  3ffe0000 0000000x4021e5f8: pbuf_alloc at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/pbuf.c:389
24 00000008 3ffeaf46  
3fffff10:  3fff3540 3ffef768 3ffef770 4021b065  
3fffff20:  00000014 000000000x4021b065: ip_input at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/core/ipv4/ip.c:559
 a4603a55 3fff2748  
3fffff30:  00000000 3fff3540 0000001c 3ffeaf38  
3fffff40:  3fffdc80 3fff3540 3fff2748 4021abc5  
3fffff50:  0000005e 3ffeefb0 000x4021abc5: ethernet_input at /Users/a020900/sming/Sming/Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip/lwip/netif/etharp.c:1379
000000 00000023  
3fffff60:  0000001a 3fff3688 00000002 4022d5b3  
3fffff70:  3ffee080 3ffeaf10 3fff0x4022d5b3: ppRxPkt at /home/xcg/workspace/debug/esp8266_nonos_sdk_core_20180510/app/pp/pp.c:1086
dcc0 3ffea6e0  
3fffff80:  4022d526 3ffee080 3fffdab0 3fff34f0  
3fffff90:  3fffdc80 00000000 3fff350x4022d526: ppRxPkt at /home/xcg/workspace/debug/esp8266_nonos_sdk_core_20180510/app/pp/pp.c:1086
40 40219773  
3fffffa0:  40000f49 3fffdab0 01000080x40219773: ets_snprintf at ??:?
1 40000f49  

====================================0x40000f49: ?? ??:0
0x40000f49: ?? ??:0
============================

also attach the HttpServer definition

void startWeb()
{
    server.listen(80);
    server.paths.set("/", onIndex);
    server.paths.setDefault(onFile);

//    auto wsResource = new WebsocketResource();
//    wsResource->setConnectionHandler(wsConnected);
//    wsResource->setMessageHandler(wsMessageReceived);
//    wsResource->setBinaryHandler(wsBinaryReceived);
//   wsResource->setDisconnectionHandler(wsDisconnected);


//    server.paths.set("/ws", wsResource);


    Serial.println(_F("\r\n=== WEB SERVER STARTED ==="));
    Serial.println(WifiStation.getIP());
    Serial.println(_F("==============================\r\n"));
}
HttpServer server;

void onIndex(HttpRequest &request, HttpResponse &response)
{
    Serial << "HomePage access" << endl;
	auto tmpl = new TemplateFileStream(F("index.html"));
	auto& vars = tmpl->variables();
    // vars["counter"] = String(counter);
    response.sendNamedStream(tmpl); // this template object will be deleted automatically
}

void onFile(HttpRequest &request, HttpResponse &response)
{
    String file = request.uri.getRelativePath();

    if (file[0] == '.')
        response.code = HTTP_STATUS_FORBIDDEN;
    else
    {
        response.setCache(86400, true); // It's important to use cache for better performance.
        response.sendFile(file);
    }
}

Probably I'm doing some trivial error ...

Thanks a lot for your support
Regards
Stefano

@slaff
Copy link
Contributor

slaff commented Dec 18, 2023

@sreggy Please put the source code that is segfaulting for you in a separate GitHub repository and paste the URL here. I will compile it for the Host architecture. And run valgrind and other tools if there is an issue.

@sreggy
Copy link
Author

sreggy commented Dec 18, 2023

Hi @slaff,
you can find my project in git at https://github.com/sreggy/ezri.git

Available for any further information.

thanks in advance
regards
Stefano

@slaff
Copy link
Contributor

slaff commented Dec 18, 2023

Since the issue is not related to CommandProcessing( see here: sreggy/ezri#1) I will close this issue. You can create a new one if you are certain that there is a problem with CommandProcessing AND provide a small/simple/sample code that demonstrates it.

@slaff slaff closed this as completed Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants