开源改变世界

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

推推 grbl 3年前 (2023-01-31) 253次浏览
关闭
cosmok82 打开了这个问题 2022 年 3 月 25 日 · 19条评论
关闭

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息#1137

cosmok82 打开了这个问题 2022 年 3 月 25 日 · 19条评论

注释

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

嗨,

我想将传感器 as5600 添加到我个人的 scara 运动学中,但是当我通过串行调用 grbl_notifyf 或 grbl_msg_sendf 时,串行监视器上没有打印消息。你知道问题出在哪里吗?我附上了一个例子:

static TaskHandle_t as5600UpdateTaskHandle;

void as5600Update(void* pvParameters) {
    TickType_t       xLastWakeTime;
    const TickType_t xDisplayFrequency = 100;                  // in ticks (typically ms)
    xLastWakeTime                      = xTaskGetTickCount();  // Initialise the xLastWakeTime variable with the current time.

    vTaskDelay(1000);
    
    while (true) {
      TCA9548A(2);
      ReadRawAngle();

      grbl_notifyf("AS5600 sensor", "Angle: %4.2f \r\n", degAngle);
      grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Verbose, "Angle: %4.2f", degAngle);

      vTaskDelayUntil(&xLastWakeTime, xDisplayFrequency);
    }
}

void as5600_init() {
    // Initialising the UI will init the display too.
    grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Init AS5600 SDA:%s SCL:%s", pinName(I2C_SDA_PIN), pinName(I2C_SCL_PIN));
    
    xTaskCreatePinnedToCore(as5600Update,                // task
                            "as5600UpdateTask",          // name for task
                            4096,                        // size of task stack
                            NULL,                        // parameters
                            1,                           // priority
                            &as5600UpdateTaskHandle,     //
                            CONFIG_ARDUINO_RUNNING_CORE  // must run the task on same core
                                                         // core
    );
}

as5600_init(); 它被添加到 Grbl.cpp 并且工作得很好,但我没有按预期从 as5600 任务初始化后读取串行上的任何状态消息。我想在开发过程中至少在调试模式下评估它,或者如果可能的话在详细模式下评估它。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

vTaskDelayUntil(&xLastWakeTime, xDisplayFrequency);

这要求它等到过去的某个时间。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137
作者

vTaskDelayUntil(&xLastWakeTime, xDisplayFrequency);

这要求它等到过去的某个时间。

抱歉,但我不明白它有什么用。例如,我尝试在 GPIO 上闪烁,它工作得很好,为什么不在串行上呢?

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

尝试从串行终端发送 $Message/Level=Verbose。或者使用 MessageLevel::Info 执行 sendf

100 毫秒对于消息来说有点快。我会把它改成500

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137
作者

我将代码更改为:


static TaskHandle_t as5600UpdateTaskHandle;

void as5600Update(void* pvParameters) {
    
    while (true) {
      TCA9548A(2);
      ReadRawAngle();

      grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Angle: %4.2f \r\n", degAngle);
      delay(1000);

    }
}

void as5600_init() {
    // Initialising the UI will init the display too.
    grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Init AS5600 SDA:%s SCL:%s", pinName(I2C_SDA_PIN), pinName(I2C_SCL_PIN));
    
    xTaskCreatePinnedToCore(as5600Update,                // task
                            "as5600UpdateTask",          // name for task
                            4096,                        // size of task stack
                            NULL,                        // parameters
                            1,                           // priority
                            &as5600UpdateTaskHandle,     //NULL
                            CONFIG_ARDUINO_RUNNING_CORE  // must run the task on same core
                                                         // core
    );
}

但是没有,它不起作用。可能是任务的问题?
串行库在不同的任务上,也许是这个。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

你真的从主初始化代码的某个地方调用了 as5600_init() 吗?

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137
作者

你真的从主初始化代码的某个地方调用了 as5600_init() 吗?

当然,正如我在第一条消息中所说的“ as5600_init();它已添加到 Grbl.cpp 中并且运行良好

这是输出:

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1216
ho 0 tail 12 room 4
load:0x40078000,len:9720
ho 0 tail 12 room 4
load:0x40080400,len:6352
entry 0x400806b8

[MSG:Init AS5600 SDA:GPIO(21) SCL:GPIO(22)]
[MSG:Grbl_ESP32 Ver 1.3a Date 20211103]
 
在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137
作者

问题是:是否可以从任务调用中调用串行?因为我研究了代码,所以我没有发现任何事件。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

我不知道为什么它不起作用。

我们不再支持 Grbl_Esp32。我们目前的所有工作都在 FluidNC 上进行。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137
作者

流体数控

对不起米奇,也许我错了,但我在 FluidNC https://github.com/bdring/FluidNC

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

此问题在 Grbl_Esp32 存储库中。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137
作者

流体数控

对不起米奇,也许我错了,但我在 FluidNC https://github.com/bdring/FluidNC

此问题在 Grbl_Esp32 存储库中。

不,我错了,我在 Grbl_Esp32 上,但我可以打开 FluidNC。不知道能不能解决我的问题。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

FluidNC 中也不存在 grbl_msg_sendf()。FluidNC 使用具有 iostream 样式格式的 log_info()。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137
作者

FluidNC 中也不存在 grbl_msg_sendf()。FluidNC 使用具有 iostream 样式格式的 log_info()。

让我尝试新项目,我可以完成配置的移植,也许支持会更好。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

我将此代码添加到 Main.cpp 作为测试:

void as5600Update(void* pvParameters) {
    log_info("Hello from task");
    while (true) {
        log_info("Ping from task");
        delay(1000);
    }
}

void as5600_init() {
    // Initialising the UI will init the display too.
    log_info("Creating task");

    xTaskCreatePinnedToCore(as5600Update,                // task
                            "as5600UpdateTask",          // name for task
                            4096,                        // size of task stack
                            NULL,                        // parameters
                            1,                           // priority
                            &as5600UpdateTaskHandle,     //NULL
                            CONFIG_ARDUINO_RUNNING_CORE  // must run the task on same core
                                                         // core
    );
}

并将其添加为 setup() 的最后一行

    as5600_init();

有效。

在任务 xTaskCreatePinnedToCore 期间没有 grbl_notifyf/grbl_msg_sendf 消息 #1137

这就是我能提供的所有帮助。