#ifdef WITH_CAN void MAIN_CANreceivedData(tCAN_struct* pCANframe) { UINT8 i; UINT8 rx_char; UINT8 i_befehl = 0; if (pCANframe->dlc == 0) return; // keine Daten #ifdef WITH_TIME can_Rx_Supervise_Timer = TIME_restart_msTimer(&can_Rx_Supervise_Timer, TIMEOUT_CAN_RX_ms, timeout_CAN_cmd_rx, 0); #endif // WITH_TIME i = 0; while (i < pCANframe->dlc) { rx_char = pCANframe->data[i++]; if (rx_char == '\n') { if (can_rx_byte_cnt > 0) { #ifdef WITH_TIME TIME_stop_msTimer(&can_Rx_Supervise_Timer); #endif // WITH_TIME aCAN_CMD_RxBuffer[can_rx_byte_cnt] = '\0'; // insert nullterminator for string manipulations if (analyze_command(SRC_CAN, &aCAN_CMD_RxBuffer[0], &respString[0]) == TRUE) { CAN_SendString((PINT8) &respString[0], 0); } #ifdef WITH_CAN clear_CAN_cmd_rx_buffer(); // prepare buffer for next command #endif // WITH_CAN } continue; } // only alphanumeric character allowed eud ASCII if (isalnum((INT8) rx_char) || rx_char == '/' || rx_char == '#') { aCAN_CMD_RxBuffer[can_rx_byte_cnt++] = rx_char; // if too much characters then something wrong -> clear buffer if (can_rx_byte_cnt >= CAN_RX_CMD_SIZE) { #ifdef WITH_CAN clear_CAN_cmd_rx_buffer(); #endif // WITH_CAN } } else { // unknown character -> look next character continue; } } // end while (len-- > 0) if (can_rx_byte_cnt > 0 && aCAN_CMD_RxBuffer[0] == '#') { #ifdef WITH_TIME TIME_stop_msTimer(&can_Rx_Supervise_Timer); #endif // WITH_TIME aCAN_CMD_RxBuffer[can_rx_byte_cnt] = '\0'; // insert nullterminator for string manipulations if (analyze_command(SRC_CAN, &aCAN_CMD_RxBuffer[0], &respString[0]) == TRUE) { CAN_SendString((PINT8) &respString[0], 0); } #ifdef WITH_CAN clear_CAN_cmd_rx_buffer(); // prepare buffer for next command #endif // WITH_CAN } } // End of MAIN_CANreceiveData() #endif // WITH_CAN