-
Notifications
You must be signed in to change notification settings - Fork 2.1k
examples/lwip_ipv4: add example for LWIP IPv4 client/server #21519
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
base: master
Are you sure you want to change the base?
examples/lwip_ipv4: add example for LWIP IPv4 client/server #21519
Conversation
30edfe6
to
b6ba8d4
Compare
I try to generate @crasbe could you add label |
I'll run it on my work computer tomorrow, then you can address the suggestions without triggering a full rebuild on every fixup. |
This is the result for BOARD_INSUFFICIENT_MEMORY := \
bluepill-stm32f030c8 \
i-nucleo-lrwan1 \
nucleo-c031c6 \
nucleo-f030r8 \
nucleo-f031k6 \
nucleo-f042k6 \
nucleo-l011k4 \
nucleo-l031k6 \
nucleo-l053r8 \
samd10-xmini \
slstk3400a \
stk3200 \
stm32f030f4-demo \
stm32f0discovery \
stm32g0316-disco \
stm32l0538-disco \
weact-g030f6 \
# |
@crasbe Thanks for |
829cea9
to
867808b
Compare
mutex_lock(&server_mutex); | ||
server_running = 0; | ||
mutex_unlock(&server_mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you need that for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea is that if due to some errors this thread ends - we could start server once again.
I tested this situation with similar code after sock_udp_recv
function (lines 98-105). When RIOT receives UDP datagram longer than 64 bytes (buffer
size) it ends with error, but I could restart server and later everything works well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why the need for a mutex?
ea3ad62
to
9a20829
Compare
All remarks from review fixed. |
Can me move this PR a little forward? |
} | ||
|
||
if (data_len != (size_t)sock_udp_send(&sock, argv[3], data_len, NULL)) { | ||
printf("Error sock_udp_send!\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You likely want to print the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I want to print error.
Your comment concerns wrong condition? You suggest add only condition for <0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sock_udp_send()
gives you an error code that can tell the user why the send failed.
mutex_lock(&server_mutex); | ||
server_running = 0; | ||
mutex_unlock(&server_mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why the need for a mutex?
return -1; | ||
} | ||
|
||
SHELL_COMMAND(server, "Starts server which receives UDP datagrams", _server_cmd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more convenient for testing if the server did auto-start.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer do not start server automatically.
This is (1) example, (2) user can from CLI start it on various port.
fbab430
to
85936e5
Compare
85936e5
to
eeb5403
Compare
Contribution description
This PR adds new example which shows how to implement LWIP IPv4 client and server.
Moreover, this example can be used in CI to check, if new code do not break LWIP IPv4.
In the previous few months at least two problems with LWIP IPv4 are detected manually,
and they should be detected by CI - see PR #21316 or PR #21342.
Testing procedure
Check
client
andserver
commands as described in theREADME.md
.Issues/PRs references
None