-
Notifications
You must be signed in to change notification settings - Fork 1
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
Migrate to new NetworkChannel interface #94
Conversation
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
4 similar comments
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
8c68249
to
70e8764
Compare
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
nanopb_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
request_shutdown_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
nanopb_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
request_shutdown_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
Memory usage after merging this PR will be: Memory Reportaction_microstep_test_c
action_test_c
delayed_conn_test_c
event_payload_pool_test_c
event_queue_test_c
nanopb_test_c
physical_action_test_c
port_test_c
reaction_queue_test_c
request_shutdown_test_c
shutdown_test_c
startup_test_c
timer_test_c
|
…hannel test inside the unit tests folder
Okay this should be finished now. I am not sure why these tests fail. It seems my unit test cannot find the tcp_ip_channel.c file, but locally it compiles and runs on my computer. The client and server seem to be non blocking now, so the configuration in tcp_ip_channel.c was successful from what I can see. I added tests for this also. But as long as everything finishes running at least we know it is non-blocking. :) 🤓 |
test/unit/mock.c
Outdated
// void setUp(void) {} |
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 am not sure. It seems there is something wrong with the cmake configuration.
I am using these functions in the new network_channels_test.c
and the compiler was complaining about multiple implementations for these functions.
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.
By commenting out these implementations in mock.c it compiled.
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.
Hm, on my end I get undefined reference errors when these functions are not there...
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.
Ah, I just defined them that way because we are not using them for any other test
} | ||
} | ||
self->super.close((NetworkChannel *)self); | ||
self->receive_thread = 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.
This is needed so that the free
function does not cleanup threads that don't exist anymore if you clean and recreate the same tcpchannel. (I noticed this when running my new unit test)
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.
Because sometimes we recreate the tcp_ip_channel but without a new thread so the thread is still closed in reality
@@ -220,7 +232,7 @@ void TcpIpChannel_register_callback(NetworkChannel *untyped_self, | |||
throw("pthread_attr_init failed"); | |||
} | |||
/* TODO: RIOT posix-wrappers don't have pthread_attr_setstack yet */ | |||
#ifdef PLATFORM_RIOT | |||
#if defined(PLATFORM_RIOT) && !defined(__USE_XOPEN2K) |
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.
When compiling for RIOT native BOARD we otherwise get a deprecated warning. Native does support the new setstack function
LF_DEBUG(NET, "Closing TCP/IP Channel"); | ||
TcpIpChannel *self = (TcpIpChannel *)untyped_self; | ||
|
||
if (self->server) { | ||
if (self->server && self->client != 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.
This extra check is needed because in my test I sometimes just open a connection only and don't actually create a client socket. Then cleaning a client socket here creates an error.
@@ -33,7 +33,6 @@ struct TcpIpChannel { | |||
|
|||
fd_set set; | |||
bool server; | |||
bool blocking; |
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.
This variable is unused
Okay I added some comments to explain some important code parts |
About the test name: I named it network channel test because except the setup function the test is implementation independent. In theory once we have more channels we could run these tests all in one place and share the code. We only need to call the correct constructors accordingly in setup But it is okay to call it tcp for now. Maybe we can revisit once we have more channels |
@@ -132,7 +144,7 @@ lf_ret_t TcpIpChannel_send(NetworkChannel *untyped_self, TaggedMessage *message) | |||
return LF_OK; | |||
} | |||
|
|||
TaggedMessage *TcpIpChannel_receive(NetworkChannel *untyped_self) { | |||
static TaggedMessage *TcpIpChannel_receive(NetworkChannel *untyped_self) { |
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 like static functions, but I like const pointers better, we should start using them also
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 agree ;)
This looks great to me. A good first step towards stabilizing the NetworkChannel! |
Closes #83
Closes #88