⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 about.c

📁 OBDII的ScanTool源码,对此有兴趣的朋友可以参考一下
💻 C
📖 第 1 页 / 共 3 页
字号:
                     response[0] = 0;
                     strcpy(obd_protocol, "detecting...");
                     state = OBD_INFO_WAIT_0100;
                     return D_REDRAW;
                  }
               }
               else  // if serial timeout
               {
                  stop_serial_timer();
                  if (retries < OBD_INFO_MAX_RETRIES)
                  {
                     retries++;
                     sprintf(obd_interface, "retrying (%i)...", retries);
                     state = OBD_INFO_TX_0100;
                     return D_REDRAW;
                  }
                  else
                  {
                     if (alert("Connection to interface was lost", NULL, NULL, "&Retry", "&Cancel", 'r', 'c') == 1)
                        state = OBD_INFO_START;
                     else
                     {
                        clear_obd_info();
                        state = OBD_INFO_IDLE;
                        return D_REDRAW;
                     }
                  }
               }
               break;

            case OBD_INFO_WAIT_ATZ:
               status = read_comport(buf);
               
               if(status == DATA) // if new data detected in com port buffer
                  strcat(response, buf); // append contents of buf to response
               else if (status == PROMPT)  // if we got the prompt
               {
                  stop_serial_timer();
                  strcat(response, buf);
                  status = process_response("atz", response);

                  strcpy(obd_interface, response);
                  strcpy(obd_mfr, "N/A");
                  
                  if (status == INTERFACE_ELM323)
                  {
                     start_serial_timer(ECU_TIMEOUT);
                     strcpy(obd_protocol, "waiting for ECU timeout...");
                     device = INTERFACE_ELM323;
                     state = OBD_INFO_ECU_TIMEOUT;
                  }
                  else if (status >= INTERFACE_ID)
                  {
                     send_command("0100");
                     start_serial_timer(OBD_REQUEST_TIMEOUT);
                     response[0] = 0;
                     strcpy(obd_protocol, "detecting...");
                     device = status;
                     state = OBD_INFO_WAIT_0100;
                  }
                  else if (status == HEX_DATA)
                  {
                     state = OBD_INFO_START;
                     break;
                  }
                  else
                  {
                     if (display_error_message(status, TRUE) == 1)
                     {
                        state = OBD_INFO_START;
                        break;
                     }
                     else
                     {
                        clear_obd_info();
                        state = OBD_INFO_IDLE;
                        return D_REDRAW;
                     }
                  }
                  
                  return D_REDRAW;
               }
               else if (serial_time_out)
               {
                  stop_serial_timer();
                  if (alert("Connection to interface was lost", NULL, NULL, "&Retry", "&Cancel", 'r', 'c') == 1)
                     state = OBD_INFO_START;
                  else
                  {
                     clear_obd_info();
                     state = OBD_INFO_IDLE;
                     return D_REDRAW;
                  }
               }
               break;

            case OBD_INFO_ECU_TIMEOUT:
               if (serial_time_out)
               {
                  stop_serial_timer();
                  send_command("0100");
                  start_serial_timer(OBD_REQUEST_TIMEOUT);
                  response[0] = 0;
                  strcpy(obd_protocol, "detecting...");
                  state = OBD_INFO_WAIT_0100;
                  return D_REDRAW;
               }
               break;

            case OBD_INFO_WAIT_0100:
               status = read_comport(buf);

               if(status == DATA) // if new data detected in com port buffer
                  strcat(response, buf); // append contents of buf to response
               else if (status == PROMPT)  // if we got the prompt
               {
                  stop_serial_timer();
                  strcat(response, buf);
                  status = process_response("0100", response);

                  if (status == HEX_DATA)
                  {
                     if (device != INTERFACE_ELM327)
                        strcpy(obd_protocol, get_protocol_string(device, 0));
                     else
                     {
                        send_command("atdpn");
                        start_serial_timer(AT_TIMEOUT);
                        response[0] = 0;

                        while ((status = read_comport(buf)) != PROMPT && !serial_time_out)
                        {
                           if (status == DATA) // if new data detected in com port buffer
                              strcat(response, buf); // append contents of buf to response
                        }

                        if (status == PROMPT)  // if we got the prompt
                        {
                           stop_serial_timer();
                           strcat(response, buf);
                           process_response("atdpn", response);

                           status = (response[0] == 'A') ? response[1] : response[0];
                           strcpy(obd_protocol, get_protocol_string(INTERFACE_ELM327, status - 48));
                        }
                        else // if serial timeout
                        {
                           stop_serial_timer();
                           if (alert("Connection to interface was lost", NULL, NULL, "&Retry", "&Cancel", 'r', 'c') == 1)
                              state = OBD_INFO_START;
                           else
                           {
                              clear_obd_info();
                              state = OBD_INFO_IDLE;
                              return D_REDRAW;
                           }
                        }
                     }
                  }
                  else
                  {
                     if (status == ERR_NO_DATA || status == UNABLE_TO_CONNECT)
                        status = alert("There may have been a loss of connection.", "Please check connection to the vehicle,", "and make sure the ignition is ON", "&Retry", "&Cancel", 'r', 'c');
                     else if (status >= INTERFACE_ID)
                        status = 1;
                     else  // all other errors
                        status = display_error_message(status, TRUE);

                     if (status == 1)
                     {
                        state = OBD_INFO_START;
                        break;
                     }
                     else
                     {
                        clear_obd_info();
                        state = OBD_INFO_IDLE;
                        return D_REDRAW;
                     }
                  }

                  send_command("011C");
                  start_serial_timer(OBD_REQUEST_TIMEOUT);
                  response[0] = 0;
                  strcpy(obd_system, "detecting...");
                  state = OBD_INFO_WAIT_011C;
                  return D_REDRAW;
               }
               else if (serial_time_out)
               {
                  stop_serial_timer();
                  if (alert("Connection to interface was lost", NULL, NULL, "&Retry", "&Cancel", 'r', 'c') == 1)
                     state = OBD_INFO_START;
                  else
                  {
                     clear_obd_info();
                     state = OBD_INFO_IDLE;
                     return D_REDRAW;
                  }
               }
               break;

            case OBD_INFO_WAIT_011C:
               status = read_comport(buf);

               if(status == DATA) // if new data detected in com port buffer
                  strcat(response, buf); // append contents of buf to response
               else if (status == PROMPT)  // if we got the prompt
               {
                  stop_serial_timer();
                  strcat(response, buf);
                  status = process_response("011C", response);

                  if (status == HEX_DATA)
                  {
                     if (find_valid_response(buf, response, "411C", NULL))
                     {
                        buf[6] = 0;  // solves problem where response is padded with zeroes
                        obd_requirements_formula((int)strtol(buf + 4, NULL, 16), buf);  // get OBD requirements string
                        strcpy(obd_system, buf);
                     }
                  }
                  else if (status == ERR_NO_DATA)
                     strcpy(obd_system, "N/A");
                  else  // other errors
                  {
                     if (display_error_message(status, TRUE) == 1)
                     {
                        state = OBD_INFO_START;
                        break;
                     }
                     else
                        clear_obd_info();
                  }

                  state = OBD_INFO_IDLE;
                  return D_REDRAW;
               }
               else if (serial_time_out)
               {
                  stop_serial_timer();
                  if (alert("Connection to interface was lost", NULL, NULL, "&Retry", "&Cancel", 'r', 'c') == 1)
                     state = OBD_INFO_START;
                  else
                  {
                     clear_obd_info();
                     state = OBD_INFO_IDLE;
                     return D_REDRAW;
                  }
               }
               break;
         }
         break;
   }

   return D_O_K;
}


int thanks_proc(int msg, DIALOG *d, int c)
{
   int ret = d_button_proc(msg, d, c);

   if (msg == MSG_START)
      centre_dialog(thanks_dialog);
   
   if (ret == D_CLOSE)
   {
      popup_dialog(thanks_dialog, -1);
      return D_REDRAWME;
   }

   return ret;
}


int large_text_proc(int msg, DIALOG *d, int c)
{
   if (msg == MSG_START)
      d->dp2 = datafile[ARIAL18_FONT].dat; // load the font

   return d_text_proc(msg, d, c);
}


int about_this_computer_proc(int msg, DIALOG *d, int c)
{
   char cpu_info_buf[96];
   char os_type_buf[96];
   char os_name[32];
   char processor_vendor[64];
   char processor_family[64];
   char processor_model[64];

   // clear strings
   cpu_info_buf[0] = 0;
   os_type_buf[0] = 0;
   os_name[0] = 0;
   processor_vendor[0] = 0;
   processor_family[0] = 0;
   processor_model[0] = 0;
   
   int ret = d_button_proc(msg, d, c);
   
   if (ret == D_CLOSE)
   {
      // reset the variables
      processor_model[0] = 0;

      // determine processor vendor
      if(strcmp("GenuineIntel", cpu_vendor) == 0)
         strcpy(processor_vendor, "an Intel");
      else if(strcmp("AuthenticAMD", cpu_vendor) == 0)
         strcpy(processor_vendor, "an AMD");
      else if(strcmp("CyrixInstead", cpu_vendor) == 0)
         strcpy(processor_vendor, "a Cyrix");
      else if(strcmp("CentaurHauls", cpu_vendor) == 0)
         strcpy(processor_vendor, "a Centaur");
      else if(strcmp("NexGenDriven", cpu_vendor) == 0)
         strcpy(processor_vendor, "a NexGen");
      else if(strcmp("GenuineTMx86", cpu_vendor) == 0)
         strcpy(processor_vendor, "a Transmeta");
      else if(strcmp("RISERISERISE", cpu_vendor) == 0)
         strcpy(processor_vendor, "a Rise");
      else if(strcmp("UMC UMC UMC", cpu_vendor) == 0)
         strcpy(processor_vendor, "an UMC");
      else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -