The procedure of the program: It is convenient to view and maintain.

The main purpose of writing the program is to read it easily in the future and to facilitate viewing and maintenance.

//Return error convention: If the command is related to the site, it will be determined whether to return error information according to the setting,
//If the command is not related to the site, it is not necessary to return Error message, all received are hexadecimal numbers
bool Inspect=true;
uint8_t ErrorCode=0;

//CRC check
……
//Analyze the file header
if (rx_buffer1[0] != 0x59 || rx_buffer1[1] != 0x51 || rx_buffer1[2]!=0x43 || rx_buffer1[3]!=0x59 ){
Inspect=false;
  ErrorCode=0x011;//Error code 11: Error identifying the file header
}

//Analyze the end of the file
if (rx_buffer1[66]!=0x59 || rx_buffer1[67]!=0x42 || rx_buffer1[68]!=0x44 || rx_buffer1[69]!=0x57 ){
  Inspect=false;
  ErrorCode=0x022;//error code 22: identification Error at the end of the file
}

//Whether it belongs to the receiving command of this line and this station
if( rx_buffer1[4]!=0x01 || rx_buffer1[6]!=0x00) {
  Inspect=false;
  ErrorCode=0x33;//Error code 33: Not this test command
}

//Whether it belongs to this line and this station Command
if( rx_buffer1[5]!=YBDWPipeline || rx_buffer1[7]!=YBDWPile ){
  Inspect=false;
  ErrorCode=0x44;//Error code 44: not this line or this site
}

……

if(Inspect==true){
  //Data to be returned

  //According to specific commands to perform actual operations
  switch(rx_buffer1[9]){
    case Set_SystemDatetime: //Set the system date and time

      break;
case Set_EngineeringOffset: //Set the engineering offset

      break;
    case Set_LineAndPile://Set the line number and station number, the start and end station number of this line

 break;

    case Set_Version://set version information

      break;
      case Get_LineAndPile://Get the line number and station number, the start and end station number of the line

      break;
    case Get_CurrentYBDW://Get current data

      break;

//Command not supported

p>      break;  }  ……}else{  if(rx_buffer1[17]==0x99 && rx_buffer1[5]!=YBDWPipeline && rx_buffer1[WPile will determine whether the error will be returned according to the configuration /  )/ / , Feedback information only with the signal of this site…  HAL_UART_Transmit(&hlpuart1,Send_Buffer,70,10); //Serial port 1 sends the entire buffer to LORA}

< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5394 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.