Failed try to send data from computer to robot
This commit is contained in:
@@ -57,6 +57,7 @@ void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
void DMA1_Channel7_IRQHandler(void);
|
||||
void TIM4_IRQHandler(void);
|
||||
void USART1_IRQHandler(void);
|
||||
void USART2_IRQHandler(void);
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
|
||||
@@ -17,10 +17,14 @@ ESP8266::~ESP8266() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void ESP8266::uart_callback(){
|
||||
uart_receive_until_termination_byte(interruptPayload, MAX_BUFFER_SIZE, '\n', 2);
|
||||
}
|
||||
|
||||
void ESP8266::init(){
|
||||
command("AT+CWMODE=1,1\r\n");
|
||||
command("AT+CWJAP=\"Gabriel_2G\",\"gabrielwifi\"\r\n");
|
||||
command("AT+CWLAP\r\n");
|
||||
//command("AT+CWLAP\r\n");
|
||||
command("AT+CIPMUX=1\r\n");
|
||||
command("AT+CIPSTART=0,\"UDP\",\"239.0.0.1\",10001,11001,0\r\n");
|
||||
}
|
||||
@@ -113,25 +117,37 @@ HAL_StatusTypeDef ESP8266::uart_receive_until_termination_byte(uint8_t *pData, u
|
||||
}
|
||||
|
||||
ESP8266::statusTypeDef ESP8266::wait_until_ok() {
|
||||
HAL_UART_AbortReceive_IT(huart);
|
||||
while(uart_receive_until_termination_byte(buffer, MAX_BUFFER_SIZE, '\n', OK_TIMEOUT) != HAL_TIMEOUT){
|
||||
if(!strcmp((char*) buffer, "OK\r\n")){
|
||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
||||
return STATUS_OK;
|
||||
}
|
||||
if(!strcmp((char*) buffer, "ERROR\r\n")){
|
||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(buffer[0] == '+'){
|
||||
|
||||
}
|
||||
}
|
||||
return STATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
ESP8266::statusTypeDef ESP8266::wait_until_send_ok() {
|
||||
HAL_UART_AbortReceive_IT(huart);
|
||||
while(uart_receive_until_termination_byte(buffer, MAX_BUFFER_SIZE, '\n', OK_TIMEOUT) != HAL_TIMEOUT){
|
||||
if(!strcmp((char*) buffer, "SEND OK\r\n")){
|
||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
||||
return STATUS_OK;
|
||||
}
|
||||
if(!strcmp((char*) buffer, "SEND ERROR\r\n")){
|
||||
HAL_UART_Receive_IT(huart, interruptHeader, 9);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
if(buffer[0] == '+'){
|
||||
|
||||
}
|
||||
}
|
||||
return STATUS_TIMEOUT;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
|
||||
ESP8266(UART_HandleTypeDef* huart);
|
||||
virtual ~ESP8266();
|
||||
void uart_callback();
|
||||
void init();
|
||||
statusTypeDef command(const char* command);
|
||||
void send_uint32(const char* name, uint32_t value);
|
||||
@@ -28,6 +29,8 @@ private:
|
||||
static const uint32_t MAX_BUFFER_SIZE = 256;
|
||||
static const uint32_t OK_TIMEOUT = 5000;
|
||||
|
||||
uint8_t interruptHeader[9];
|
||||
uint8_t interruptPayload[MAX_BUFFER_SIZE];
|
||||
statusTypeDef send(const char* data);
|
||||
HAL_StatusTypeDef wait_on_flag_until_timeout(uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout);
|
||||
HAL_StatusTypeDef uart_receive_until_termination_byte(uint8_t *pData, uint16_t Size, uint8_t terminationByte, uint32_t Timeout);
|
||||
|
||||
@@ -23,6 +23,12 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
||||
if(huart == &huart1){
|
||||
esp0.uart_callback();
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
|
||||
if(huart == &huart2){
|
||||
debug.serialTxCpltCallback();
|
||||
@@ -57,14 +63,14 @@ void start(){
|
||||
debug.debug("ATE0 TIMEOUT");
|
||||
break;
|
||||
}
|
||||
esp0.init();
|
||||
//+IPD,0,14:Hello World 01\r\n
|
||||
debug.info("Init ESP8266 end");
|
||||
while(true){
|
||||
HAL_GPIO_WritePin(LED_BUILTIN_GPIO_Port, LED_BUILTIN_Pin, (GPIO_PinState)(TIM1->CNT & 0b00000000000000000000000000000001));
|
||||
esp0.send_uint32("TIM1->CNT", TIM1->CNT);
|
||||
sprintf(buf, "TIM1->CNT: %lu", TIM1->CNT);
|
||||
debug.debug(buf);
|
||||
HAL_Delay(10);
|
||||
/*sprintf(buf, "TIM1->CNT: %lu", TIM1->CNT);
|
||||
debug.debug(buf);*/
|
||||
//HAL_Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -349,6 +349,9 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
|
||||
__HAL_AFIO_REMAP_USART1_ENABLE();
|
||||
|
||||
/* USART1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(USART1_IRQn, 7, 0);
|
||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||
/* USER CODE BEGIN USART1_MspInit 1 */
|
||||
|
||||
/* USER CODE END USART1_MspInit 1 */
|
||||
@@ -425,6 +428,8 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
|
||||
|
||||
/* USART1 interrupt DeInit */
|
||||
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
||||
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END USART1_MspDeInit 1 */
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
/* External variables --------------------------------------------------------*/
|
||||
extern TIM_HandleTypeDef htim4;
|
||||
extern DMA_HandleTypeDef hdma_usart2_tx;
|
||||
extern UART_HandleTypeDef huart1;
|
||||
extern UART_HandleTypeDef huart2;
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
@@ -228,6 +229,20 @@ void TIM4_IRQHandler(void)
|
||||
/* USER CODE END TIM4_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USART1 global interrupt.
|
||||
*/
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 0 */
|
||||
HAL_UART_IRQHandler(&huart1);
|
||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||
|
||||
/* USER CODE END USART1_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles USART2 global interrupt.
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -74,6 +74,7 @@ NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:false
|
||||
NVIC.TIM4_IRQn=true\:15\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USART1_IRQn=true\:7\:0\:true\:false\:true\:true\:true\:true
|
||||
NVIC.USART2_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||
PA11.Mode=Device
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user