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

Incorrect socket details for 'net' and 'http' on pico-w board #549

Closed
c6fc opened this issue Jan 4, 2023 · 14 comments
Closed

Incorrect socket details for 'net' and 'http' on pico-w board #549

c6fc opened this issue Jan 4, 2023 · 14 comments
Assignees

Comments

@c6fc
Copy link

c6fc commented Jan 4, 2023

Using the kaluma-rp2-pico-w-1.1.0-beta.1.uf2 release, the 'createServer' method for 'net' and 'http' modules shows incorrect details for connected sockets:

image

In both cases, calls to '.write()' methods fail to deliver the data back to the client, but no errors are returned and the callbacks for both '.write()' and '.end()' execute normally. I haven't been able to verify what the outbound packet from the pico-w look like (so I don't know if injecting the correct raddr and rport will cause the data to be delivered), but at the moment it seems that the incorrect socket details are preventing server responses from reaching the client.

@communix
Copy link
Collaborator

communix commented Jan 9, 2023

@c6fc Could you share the source code you tested? I want to reproduce the same issue on my setup.

@communix communix self-assigned this Jan 9, 2023
@c6fc
Copy link
Author

c6fc commented Jan 9, 2023

Sure thing. These are both after a lot of iterations during testing, so they're super ugly, but it should be reproducible for you:

https://gist.github.com/c6fc/49d27fb60b8313029d756e497a6b7bfd
https://gist.github.com/c6fc/dd95af62477d184a96863d496603e469

communix added a commit that referenced this issue Jan 16, 2023
@communix
Copy link
Collaborator

@c6fc Thank you for your information. I found some issues on the current FW.
One of the issue is that tcp server is not reset at soft reset. So we need to have hard reset to run a tcp server.
I fix this issue and upload new code in the pico-w branch. please test with this FW and let me know your test result.
https://github.com/kaluma-project/kaluma/tree/pico-w

@c6fc
Copy link
Author

c6fc commented Jan 18, 2023

if I use the uf2 I built with node build --target=rp2 --board=pico-w on the current pico-w branch, I get the following error on upload.

Screenshot from 2023-01-18 09-19-55

If I switch back to the public release pico-w-1.1.0-beta.1 UF2, I don't get this error. Are there additional arguments required for the pico-w build to get the drivers passed into it?

@communix
Copy link
Collaborator

@c6fc It's strange. there's no changes related to the wifi driver.
Could you please try it with .reset command before .load command?

And please use attached uf2 file which I used for this test.

kaluma-rp2-pico-w-1.1.0-beta.1_pico_w_test_0118.uf2.zip

@etx
Copy link

etx commented Feb 6, 2023

@communix I just gave this latest uf2 a try. net.createServer seems to work correctly once. I can do a res.write to send a string back to the client (netcat in this case). After that one connection I have to hard reset to make another connection. Unfortunately http.createServer is hanging when I call it.

For both I'm just using the example code from the docs.

Appreciate your work on this!!

@emerson-a
Copy link

emerson-a commented Feb 12, 2023

I have the same issue.

Tried it both with the current FW and kaluma-rp2-pico-w-1.1.0-beta.1_pico_w_test_0118.uf2.zip
Same result on both, only works once.
Here's my code: https://gist.github.com/emerson-a/d48df41f8431ebcb3ed516f17485d7ef

I also appreciate your work on this!

@communix
Copy link
Collaborator

@etx @emerson-a Thank you for your feedback. let me check it.

@communix
Copy link
Collaborator

@emerson-a @etx
Could you please try it with this binary? http.create server is working with this code.
But I can't reproduce the hard reset issue, (After that one connection I have to hard reset to make another connection.) If you still have the same issue, please create new issue with the detailed scenario.

kaluma-rp2-pico-w-1.1.0-beta.1_pico_w_test_0212.uf2.zip

@K4ST0R
Copy link

K4ST0R commented Feb 18, 2023

I got the same issue than @emerson-a and @etx .

After one connection, I can't make another connection.

I try to debug it but I am really struggling. It seems to have a link with the code using the listen fd to manage the connection with the client.

Changing :

static err_t __tcp_server_accept_cb(void *arg, struct tcp_pcb *newpcb,
err_t err) {
if (err == ERR_OK) {
uint8_t *fd = (uint8_t *)arg;

by

static err_t __tcp_server_accept_cb(void *arg, struct tcp_pcb *newpcb,
                                    err_t err) {
  if (err == ERR_OK)  {
 // test create fd
  uint8_t *oldFd = (uint8_t *)arg;
  int fdV = km_get_socket_fd();
  uint8_t *fd = &fdV;
  memcpy(&__socket_info.socket[*fd], &__socket_info.socket[*oldFd], sizeof(__socket_data_t));
  __socket_info.socket[*fd].fd = fdV;

(Sorry for the really bad code!)

I am able to connect again with another client but i can't connect two client in parallel.

@emerson-a
Copy link

@emerson-a @etx Could you please try it with this binary? http.create server is working with this code. But I can't reproduce the hard reset issue, (After that one connection I have to hard reset to make another connection.) If you still have the same issue, please create new issue with the detailed scenario.

kaluma-rp2-pico-w-1.1.0-beta.1_pico_w_test_0212.uf2.zip

I have tested this but the same issue occurs. I can only make one http connection.

Thanks again for your work on this!

@communix
Copy link
Collaborator

@emeson-a, @K4ST0R Thank you for your feedback. I think the remaining issue issue is two client support. I have created new issue about is (#557), So let's discuss this issue at #557. I'll close this issue.
If anyone find new issue or the issue which is not fixed now, please create new issue. I'll take a look this issue.

@etx
Copy link

etx commented Feb 19, 2023

@communix Could you post the JS file you're flashing to test http.createServer? I'm still having a hard time getting it to work. Thank you!

@communix
Copy link
Collaborator

@etx I'm testing with the @emerson-a 's code. https://gist.github.com/emerson-a/d48df41f8431ebcb3ed516f17485d7ef

communix added a commit that referenced this issue Mar 7, 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

5 participants