|
|
@ -132,6 +132,47 @@ void Handler::OpenMVRx_Handler(uint8_t* mac)
|
|
|
|
|
|
|
|
|
|
|
|
void Handler::MainCarRx_Handler(uint8_t* com)
|
|
|
|
void Handler::MainCarRx_Handler(uint8_t* com)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
CommandDecoder decoder(com);
|
|
|
|
|
|
|
|
if (!decoder.CommandValidate())
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(decoder.GetMainCommand())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case CommandData::MainCarCommand::StartRun:
|
|
|
|
|
|
|
|
if (decoder.GetDataBit(1) == CommandData::MainCarCommand::StartRunSub)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int point_cnt = 0;
|
|
|
|
|
|
|
|
AutoPathRunner::MapPoint* points = AutoPathRunner::DecodeRoute("B7-B6-D6-F6-F4-D4-B4-B2-D2-D1", point_cnt);
|
|
|
|
|
|
|
|
AutoPathRunner::DoRun(points, point_cnt, AutoPathRunner::CarHeadPosition::X_Positive);
|
|
|
|
|
|
|
|
delay(1500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CommandData::MainCarCommand::RunningRoute:
|
|
|
|
|
|
|
|
dynamic_route_recv = "";
|
|
|
|
|
|
|
|
dynamic_route_recv.concat((char)decoder.GetDataBit(1));
|
|
|
|
|
|
|
|
dynamic_route_recv.concat((char)decoder.GetDataBit(2));
|
|
|
|
|
|
|
|
dynamic_route_recv.concat('-');
|
|
|
|
|
|
|
|
Serial.print("Route Command: ");
|
|
|
|
|
|
|
|
Serial.println(dynamic_route_recv);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CommandData::MainCarCommand::RunningRouteData:
|
|
|
|
|
|
|
|
dynamic_route_recv.concat((char)decoder.GetDataBit(1));
|
|
|
|
|
|
|
|
dynamic_route_recv.concat((char)decoder.GetDataBit(2));
|
|
|
|
|
|
|
|
if (decoder.GetDataBit(3) == CommandData::MainCarCommand::RouteDataStop)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Serial.println(dynamic_route_recv);
|
|
|
|
|
|
|
|
Serial.println("Run!");
|
|
|
|
|
|
|
|
int point_cnt = 0;
|
|
|
|
|
|
|
|
AutoPathRunner::MapPoint* points = AutoPathRunner::DecodeRoute(dynamic_route_recv.c_str(), point_cnt);
|
|
|
|
|
|
|
|
AutoPathRunner::DoRun(points, point_cnt, AutoPathRunner::CarHeadPosition::X_Positive);
|
|
|
|
|
|
|
|
delay(1500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dynamic_route_recv.concat('-');
|
|
|
|
|
|
|
|
Serial.println(dynamic_route_recv);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
switch (com[2])
|
|
|
|
switch (com[2])
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 0x01: //ֹͣ
|
|
|
|
case 0x01: //ֹͣ
|
|
|
|