Os events stop working after starting connection #130
Closed
tommasoclini
started this conversation in
General
Replies: 1 comment
-
Sorry again for wasting your time, the only problem was task priorities, now that I've adjusted them it works |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using the lwesp library on an stm32f411re nucleo board, I'm trying to make a button send a udp message to a host, to detect the button an ISR gets called and it sets an event flag, which then unblocks a task waiting for that flang to send the udp message, the problem is that afterthe udp connection starts, the task remain blocked, os events seem to not work anymore.
I've tried just toggling an led, but nothing, before it started the connection everything works fine, the led toggles on the press of the button, but after connection initialization it is unresponsive.
I've then tried creating another task that sets the event flag every 100 milliseconds, the osEventFlagsSet function gets called, but the other task wich is responsible for toggling the led on the event is stuck waiting for the event. I've tried putting a timeout to the osEventFlagsWait and then checking if any flag was set, but even that doesn't seem to work.
Here's the main.c file(without the wait timeout) relevant parts:
/**
\brief Event callback function for connection-only
\param[in] evt: Event information with data
\return \ref lwespOK on success, member of \ref lwespr_t otherwise
*/
/**
*/
void client_connect(void) {
//lwesp_conn_start(NULL, LWESP_CONN_TYPE_TCP, CONN_HOST, CONN_PORT, NULL, conn_callback_func, 0);
/*
//lwesp_conn_start(NULL, LWESP_CONN_TYPE_TCP, CONN_HOST, 10, NULL, conn_callback_func, 0);
}
static lwespr_t conn_callback_func(lwesp_evt_t *evt) {
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin == B1_Pin) {
osEventFlagsSet(Button1Handle, Button1_Pressed_Flag);
} else {
__NOP();
}
}
/* USER CODE END 4 */
/* USER CODE BEGIN Header_StartDefaultTask /
/*
@brief Function implementing the defaultTask thread.
@param argument: Not used
@RetVal None
/
/ USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void argument)
{
/ USER CODE BEGIN 5 /
//lwespr_t res;
/ Infinite loop */
for (;;) {
osEventFlagsSet(Button1Handle, Button1_Pressed_Flag);
osDelay(100);
}
/* USER CODE END 5 */
}
/* USER CODE BEGIN Header_Startinit_thread /
/*
@brief Function implementing the init_thread thread.
@param argument: Not used
@RetVal None
/
/ USER CODE END Header_Startinit_thread */
void Startinit_thread(void argument)
{
/ USER CODE BEGIN Startinit_thread */
printf("Initializing LwESP\r\n");
while (1) {
lwespr_t error = lwesp_init(NULL, 1);
if (error != lwespOK) {
printf("Failed initializing LwESP, error: %i, retrying\r\n", error);
osDelay(1000 / portTICK_PERIOD_MS);
} else {
printf("Correctly initialized LwESP\r\n");
break;
}
}
printf("Joining AP\r\n");
while (1) {
if (lwesp_sta_join(ssid, password, NULL, NULL, NULL, 1) != lwespOK) {
printf("Failed joining %s, retrying\r\n", ssid);
} else {
printf("Joined %s\r\n", ssid);
break;
}
}
lwesp_ip_t sta_ip = { .ip = { 0, 0, 0, 0 } };
lwesp_sta_getip(&sta_ip, NULL, NULL, NULL, NULL, 1);
printf("Station IP: %i.%i.%i.%i\r\n", sta_ip.ip[0], sta_ip.ip[1], sta_ip.ip[2], sta_ip.ip[3]);
client_connect();
/* Infinite loop /
for (;;) {
osDelay(10);
}
/ USER CODE END Startinit_thread */
}
/* USER CODE BEGIN Header_Startblink /
/*
/
/ USER CODE END Header_Startblink */
void Startblink(void argument)
{
/ USER CODE BEGIN Startblink /
/ Infinite loop /
for(;;)
{
osEventFlagsWait(Button1Handle, Button1_Pressed_Flag, osFlagsWaitAll, osWaitForever);
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
}
/ USER CODE END Startblink */
}
Am I doing something wrong? I searched through the documentation but didn't find anything about os parts being stopped
Beta Was this translation helpful? Give feedback.
All reactions