Closed Glowman554 closed 1 year ago
Is this return required?
if(xTaskGetTickCount() - start >= (timeout/portTICK_PERIOD_MS)) {
ESP_LOGE(TAG, "WaitForIdle Timeout timeout=%lu", timeout);
LoRaError(ERR_IDLE_TIMEOUT);
return;
}
it is there that if the error function returns that the function does not execute code even though a error happened
I don't understand your content.
LoRaError() is an endless loop and does not return.
void LoRaErrorDefault(int error)
{
if (debugPrint) {
ESP_LOGE(TAG, "LoRaErrorDefault=%d", error);
}
while (true) {
vTaskDelay(1);
}
}
__attribute__ ((weak, alias ("LoRaErrorDefault"))) void LoRaError(int error);
There is no return here.
if ((GetStatus() & 0x70) != 0x50) {
ESP_LOGE(TAG, "SetRx Illegal Status");
LoRaError(ERR_INVALID_SETRX_STATE);
}
If the user defined function returns. And the other functions do not need to return since it is at the end of the function anyways
I still don't understand your point of view.
It is no longer safe for the user-defined function to return at this point.
if ((GetStatus() & 0x70) != 0x60) {
ESP_LOGE(TAG, "SetTx Illegal Status");
LoRaError(ERR_INVALID_SETTX_STATE);
}
I understand that. the return is only there that in case the user decides to ignore the erro (which they shouldnt do) it cant end up in an endless loop
As for WaitForIdle(), if it doesn't become Idle for a certain period of time, I don't think you can ignore it and continue processing.
I think that what you can do when it does not become Idle for a certain period of time is one of the following.
Now let's go back to the first topic.
The purpose of this assignment was to automatically restart when an error was detected.
What are its advantages?
I don't understand the advantage.
What are your assumptions about the error situation and what happens when it reboot?
Have you ever experienced an actual error and a reboot fixed it?
I've never encountered an error, so I don't understand the situation.
rebooting isnt the only option to handle the error. i would like to exit the task and send a error message in my project. one possible example is the spi transaction error i had
the advantage is that the user decides what happens when a error happend
i would like to exit the task and send a error message in my project.
this is a good idea.
the advantage is that the user decides what happens when a error happend
understood
Adding returns here should be carefully considered.
void WaitForIdle(unsigned long timeout)
{
//unsigned long start = millis();
TickType_t start = xTaskGetTickCount();
delayMicroseconds(1);
while(gpio_get_level(SX126x_BUSY)) {
delayMicroseconds(1);
//if(millis() - start >= timeout) {
if(xTaskGetTickCount() - start >= (timeout/portTICK_PERIOD_MS)) {
ESP_LOGE(TAG, "WaitForIdle Timeout timeout=%lu", timeout);
LoRaError(ERR_IDLE_TIMEOUT);
//return;
}
}
}
This allows the user to specify whether to continue, quit, or restart when an error occurs.
#if 0
void WaitForIdle(unsigned long timeout)
{
//unsigned long start = millis();
TickType_t start = xTaskGetTickCount();
delayMicroseconds(1);
while(gpio_get_level(SX126x_BUSY)) {
delayMicroseconds(1);
//if(millis() - start >= timeout) {
if(xTaskGetTickCount() - start >= (timeout/portTICK_PERIOD_MS)) {
ESP_LOGE(TAG, "WaitForIdle Timeout timeout=%lu", timeout);
while(1) { vTaskDelay(1); }
}
}
}
#endif
void WaitForIdle(unsigned long timeout)
{
//unsigned long start = millis();
TickType_t start = xTaskGetTickCount();
delayMicroseconds(1);
while(xTaskGetTickCount() - start < (timeout/portTICK_PERIOD_MS)) {
if (gpio_get_level(SX126x_BUSY) == 0) break;
delayMicroseconds(1);
}
if (gpio_get_level(SX126x_BUSY)) {
ESP_LOGE(TAG, "WaitForIdle Timeout timeout=%lu", timeout);
LoRaError(ERR_IDLE_TIMEOUT);
}
}
tbh i don't see how that changes anything but i changed it anyways
Anything new?
I support issues for other libraries.
please wait a little bit.
Anything new?
Now testing.
Anything new?
Just define a LoRaError(int error) function. If not defined LoRaErrorDefault is used