timertask - 所以我正在运行一个 ESP32,我目前将它设置为执行 2 个任务。由于看门狗定时器,核心 0 正在中止
问题描述
Task1 在 core 0 上运行 Task2 在 core 1 上运行 从机 1 数据寄存器 40007 的响应失败!从机 1 数据寄存器 40008 的响应失败!从机 1 数据寄存器 40020 的响应失败!从机 1 数据寄存器 40021 的响应失败!E (13183) task_wdt:任务看门狗被触发。以下任务未及时重置看门狗: E (13183) task_wdt: - IDLE0 (CPU 0) E (13183) task_wdt: 当前运行的任务: E (13183) task_wdt: CPU 0: Task1 E (13183) task_wdt: CPU 1:loopTask E (13183) task_wdt:正在中止。abort() 在核心 0 上的 PC 0x400d606b 被调用
Backtrace: 0x40090bbc:0x3ffbe190 0x40090ded:0x3ffbe1b0 0x400d606b:0x3ffbe1d0 0x40084af5:0x3ffbe1f0 0x400d1585:0x3ffc79b0 0x400d19ef:0x3ffc79d0 0x400d1e85:0x3ffc79f0 0x400d2996:0x3ffc7a10 0x4008d6b9:0x3ffc7a30
正在重新启动...
解决方案
void setup() {
// put your setup code here, to run once:
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
// Init in receive mode
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
// Modbus communication runs at 9600 baud
Serial2.begin(9600);
// Modbus slave ID 1
node.begin(1, Serial2);
// Callbacks allow us to configure the RS485 transceiver correctly
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
Serial.begin(38400);
while (!Serial); //while not serial Wait...
delay(1500);
Serial.println("Program has Started");
for(int i=0; i<InArraySize; i++){
pinMode(iPins[i],INPUT_PULLUP); //To enable PULL-UP resistors change "INPUT" with "INPUT_PULLUP"
}
for(int i=0; i<OutArraySize; i++){
pinMode(oPins[i],OUTPUT);
}
//interrupt-tag
// start the Modbus RTU client
initTCC();
//rtc1-tag
digitalWrite(13, HIGH);
xTaskCreatePinnedToCore(
Task1code, /* Function to implement the task */
"Task1", /* Name of the task */
10000, /* Stack size in words */
NULL, /* Task input parameter */
0, /* Priority of the task */
&Task1, /* Task handle. */
0); /* Core where the task should run */
xTaskCreatePinnedToCore(
Task2code, /* Task function. */
"Task2", /* name of task. */
10000, /* Stack size of task */
NULL, /* parameter of the task */
1, /* priority of the task */
&Task2, /* Task handle to keep track of created task */
1); /* Core where the task should run */
/**************************************Bluetooth*****************************************/
/*Serial.begin(115200);
SerialBT.begin("ESP32test"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
*/
// esp_task_wdt_init(7, true); //watchdog
// esp_task_wdt_add(Task1); //watchdog
}
void Task1code( void * pvParameter)
{
Serial.print("Task1 running on core ");
Serial.println(xPortGetCoreID());
for(;;)
{
mainRoutine();
updateRegisters();
}
// esp_task_wdt_reset(); //watchdog
}
void Task2code( void * pvParameter)
{
Serial.print("Task2 running on core ");
Serial.println(xPortGetCoreID());
for(;;)
{
/**************************************Bluetooth*****************************************/
/*if (Serial.available())
{
SerialBT.write(Serial.read());
}
if (SerialBT.available())
{
Serial.write(SerialBT.read());
}
delay(20);
*/
if ((millis()-pollTemp)>pollInterval){
pollDone=true;
//using mod move (unit id ,place to store data, data target address)
//using mod move (unit id, place to store data, data target address, min value, max value)
nFile[0]=(int16_t)modMove(0x06); //hz xx.x
mainRoutine();
updateRegisters();
nFile[7]=(int16_t)modMove(0x07); //Amps xx.x
mainRoutine();
updateRegisters();
nFile[2]=(int16_t)modMoveScaled(0x13, 0, 1000); //Analog value 1 (0-1000=(0-1000) for a percentage
mainRoutine();
updateRegisters();
nFile[3]=(int16_t)modMoveScaled(0x14, 0, 1000); //Analog value 2 (200-1000)=(0-1000) for a percentage
mainRoutine();
updateRegisters();
nFile[8]=(int16_t)modMove(0x16); //DC Bus Voltage
mainRoutine();
updateRegisters();
nFile[6]=(int16_t)modMove(0xAC); //Motor Rated Current xx.x
} else {
pollDone=false;
}
if (pollDone){
pollTemp=millis();
}
if ((millis()-pollTemp2)>pollInterval2){
pollDone2=true;
Serial.print("The current setpoint setpoint is: ");
Serial.println(nFile[2]);
Serial.print("The current wakeup point setpoint is: ");
Serial.println(nFile[4]);
Serial.print("PSI at setpoint: ");
Serial.println(getBitWord(2, 0, 0));
Serial.print("PSI at wakeup point: ");
Serial.println(getBitWord(2, 0, 1));
Serial.print("Start sleep timer: ");
Serial.println(getBitWord(2, 0, 2));
Serial.print("Hz at 60: ");
Serial.println(getBitWord(2, 0, 3));
Serial.print("Torque <= 46%: ");
Serial.println(getBitWord(2, 0, 4));
Serial.print("Start fault1 timer: ");
Serial.println(getBitWord(2, 0, 5));
Serial.print("Drive Running: ");
Serial.println(getBitWord(2, 0, 7));
Serial.print("Comm Fault: ");
Serial.println(getBitWord(2, 1, 0));
Serial.print("Underload fault: ");
Serial.println(getBitWord(2, 1, 1));
Serial.print("current reset state: ");
Serial.println(!getBitWord(0, 0, 1));
Serial.print("Flosting point torque= ");
Serial.println(fFile[2]);
} else {
pollDone2=false;
}
if (pollDone2){
pollTemp2=millis();
}
}
}
推荐阅读
- javascript - 无法在 Botpress (axios) 上使用外部 API
- reactjs - React Hooks:“useMutationEffect”和“useLayoutEffect”有什么区别?
- python - Python打印二进制数的格式
- azure-devops - 作为本地系统运行时,VSTS 代理服务无法获取代码覆盖率数据
- c# - 当前的 .Net SDK 不支持针对 .Net Core 2.2 目标 .Net Core 2.1 或更低版本
- asp.net - List 的返回类
和 int 从 Action 到另一个 Action ASP.Net MVC - java - SearchView 关闭后无法恢复搜索功能
- git - SVN 到 Git 镜像:git svn fetch -> 校验和不匹配
- tensorflow - 替换“从 tensorflow.contrib 导入层”
- java - 对象变量