Commit 25a6b60b by Hideaki Tai

add remote cmd to change xbee timeout (ms)

parent c389ae74
...@@ -12,7 +12,7 @@ static constexpr uint32_t WHILL_SERIAL_BAUD = 38400; ...@@ -12,7 +12,7 @@ static constexpr uint32_t WHILL_SERIAL_BAUD = 38400;
static constexpr uint32_t XBEE_SERIAL_BAUD = 38400; static constexpr uint32_t XBEE_SERIAL_BAUD = 38400;
static constexpr uint16_t WHILL_INFO_INTERVAL_MS = 500; static constexpr uint16_t WHILL_INFO_INTERVAL_MS = 500;
static constexpr double XBEE_COMMAND_TIMEOUT_MS = 1000.; static double xbee_cmd_timeout_ms = 300.;
uint8_t HARDWARE_ID = 0xFF; uint8_t HARDWARE_ID = 0xFF;
bool b_need_xbee_init = false; bool b_need_xbee_init = false;
......
...@@ -265,7 +265,7 @@ void setVelocity() ...@@ -265,7 +265,7 @@ void setVelocity()
fps.update(); fps.update();
if (stopwatch.isRunning()) if (stopwatch.isRunning())
{ {
if (stopwatch.ms() < XBEE_COMMAND_TIMEOUT_MS) if (stopwatch.ms() < xbee_cmd_timeout_ms)
{ {
if (b_motor_active) if (b_motor_active)
{ {
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include <queue> #include <queue>
#include <array> #include <array>
#include "../../include/global.h" // TODO: dirty
namespace BorderXBeeProtocol namespace BorderXBeeProtocol
{ {
static constexpr uint8_t BYTE_HEDADER = 0xFF; static constexpr uint8_t BYTE_HEDADER = 0xFF;
...@@ -133,6 +135,30 @@ public: ...@@ -133,6 +135,30 @@ public:
buffer.data[buffer.size] = data; buffer.data[buffer.size] = data;
++buffer.size; ++buffer.size;
} }
else if (buffer.id == 252) // change XBee timeout interval
{
if (data == BorderXBeeProtocol::BYTE_FOOTER)
{
if (buffer.size != 2)
{
Serial.print("XBee Timeout Interval recv data size error!!!! size = ");
Serial.println(buffer.size);
++error_count;
}
else
{
uint16_t ms = (uint16_t)(buffer.data[1] << 8);
ms |= (uint16_t)(buffer.data[0] << 0);
xbee_cmd_timeout_ms = (double)ms;
Serial.print("xbee timeout is changed to ");
Serial.println(xbee_cmd_timeout_ms);
}
clearPacket();
break;
}
buffer.data[buffer.size] = data;
++buffer.size;
}
else else
{ {
Serial.print("undefined CMD error!!!! CMD ID = "); Serial.print("undefined CMD error!!!! CMD ID = ");
......
  • Markdown is supported
    0% or
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or sign in to comment