send cmd to robi via uart not rs485, mode tested, without speed, no battery for robi left :/

main
Simon Frei 4 years ago
parent 15efffc08d
commit 2ed8bec6d6
  1. 16
      ADIS_ESP32_Eclipse/main/robo_wrapper.c

@ -9,8 +9,8 @@
#include "McuShell.h" #include "McuShell.h"
#include "Shell.h" #include "Shell.h"
#define RS_CMD_DRIVE_PREFIX "rs sendcmd 0x01 drive " #define RS_CMD_DRIVE_PREFIX "drive "
#define RS_CMD_TURN_PREFIX "rs sendcmd 0x01 turn " #define RS_CMD_TURN_PREFIX "turn "
#define BUF_SIZE 50 #define BUF_SIZE 50
/* Sets the robot to automatic / manual mode */ /* Sets the robot to automatic / manual mode */
@ -19,12 +19,12 @@ bool Robo_Wrapper_SetMode(bool automatic){
/* tbd */ /* tbd */
}else{ }else{
/* set speed to zero */ /* set speed to zero */
Robo_Wrapper_Nav_Move(0); unsigned char response[128];
SHELL_SendToRobotAndGetResponse((const unsigned char*)"drive speed 0 0", response, sizeof(response));
/* set mode to speed */ /* set mode to speed */
unsigned char cmd[BUF_SIZE] = RS_CMD_DRIVE_PREFIX; unsigned char cmd[BUF_SIZE] = RS_CMD_DRIVE_PREFIX;
unsigned char response[128];
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"mode speed"); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"mode speed");
SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response)); SHELL_SendToRobotAndGetResponse(cmd, response, sizeof(response));
McuShell_SendStr(response, McuShell_GetStdio()->stdOut); McuShell_SendStr(response, McuShell_GetStdio()->stdOut);
} }
return true; return true;
@ -37,7 +37,7 @@ bool Robo_Wrapper_Nav_Turn(int16_t angle){
unsigned char angleA[5] = ""; unsigned char angleA[5] = "";
McuUtility_Num16sToStr(angleA, sizeof(angleA), angle); McuUtility_Num16sToStr(angleA, sizeof(angleA), angle);
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)angleA); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)angleA);
SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response)); SHELL_SendToRobotAndGetResponse(cmd, response, sizeof(response));
McuShell_SendStr(response, McuShell_GetStdio()->stdOut); McuShell_SendStr(response, McuShell_GetStdio()->stdOut);
return true; return true;
} }
@ -52,7 +52,7 @@ bool Robo_Wrapper_Nav_Move(int16_t speed){
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)speedA); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)speedA);
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)" "); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)" ");
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)speedA); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)speedA);
SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response)); SHELL_SendToRobotAndGetResponse(cmd, response, sizeof(response));
McuShell_SendStr(response, McuShell_GetStdio()->stdOut); McuShell_SendStr(response, McuShell_GetStdio()->stdOut);
return true; return true;
} }
@ -62,7 +62,7 @@ bool Robo_Wrapper_Nav_Stop(void){
unsigned char cmd[BUF_SIZE] = RS_CMD_DRIVE_PREFIX; unsigned char cmd[BUF_SIZE] = RS_CMD_DRIVE_PREFIX;
unsigned char response[128]; unsigned char response[128];
McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"mode stop"); McuUtility_strcat(cmd, sizeof(cmd), (unsigned char*)"mode stop");
SHELL_SendToESPAndGetResponse(cmd, response, sizeof(response)); SHELL_SendToRobotAndGetResponse(cmd, response, sizeof(response));
McuShell_SendStr(response, McuShell_GetStdio()->stdOut); McuShell_SendStr(response, McuShell_GetStdio()->stdOut);
return true; return true;
} }

Loading…
Cancel
Save