| | |
| | | #include "system_mem_para.h" |
| | | #include "wrc_sizhu_v4.h" |
| | | #include "system_general_para.h" |
| | | #include "linked_list.h" |
| | | |
| | | WRC_CTRL_PARA_T wrc_ctrl_para_g={.wrc_state=WRC_IDLE,.link_status = LINK_NONE,.wrc_err_code = WRC_ERR_NONE}; |
| | | WRC_CTRL_PARA_T wrc_ctrl_para_g={.wrc_state=WRC_IDLE,.link_status = LINK_NONE,.wrc_err_code = WRC_ERR_NONE,.report_result_flag = FAIL}; |
| | | WRC_UART_PARA_T wrc_uart_para_g = {.recv_flag = RESET}; |
| | | LINK_INFO_T link_info_g; |
| | | |
| | |
| | | { |
| | | OutputIO(WRC_PWR_PORT,WRC_PWR_PIN,OUT_PUSHPULL); |
| | | OutputIO(PWR_3V8_O_PORT,PWR_3V8_O_PIN,OUT_PUSHPULL); |
| | | CloseIO(PWR_3V8_EN_PORT,PWR_3V8_EN_PIN); |
| | | PWR_3V8_OFF; |
| | | WRC_PWR_OFF; |
| | | } |
| | | |
| | | |
| | |
| | | check_sum += *(buf_p + count_i); |
| | | |
| | | if(*(buf_p + 89) == check_sum){ |
| | | |
| | | WRC_RX_DMA_CH3_reload(); //Êý¾ÝУÑéͨ¹ý¿ÉÒÔÈÏΪµ±´ÎÏëÒª½ÓÊÕµÄÊý¾ÝÒѾÍê³É£¬ÐèÒªÖØÖÃDMA½ÓÊÕ, |
| | | |
| | | if(*(buf_p + 2) == 1){ |
| | | return_flag = LINK_OK; |
| | | if((*(buf_p+3) != 1)&&(*(buf_p+3) <0x39)){ |
| | |
| | | if(buf_p != NULL){ |
| | | buf_next_p = strstr(buf_p , ","); |
| | | if(buf_next_p != NULL){ |
| | | __SYS_DELAY_SEC_TIME_SET_(wrc_timeout_para,wrc_ctrl_para_g.time_out_time_sec);//ÔÝʱ·ÅÔÚ½ÓÊÕµ½+R¾Í³äÖµ³¬Ê±Ê±¼ä£¬¸üºÏÀíµÄÓ¦¸Ã·ÅÔÚÐÒéÖ¡¸ñʽÅжϳɹ¦²¢ÏìÓ¦Êý¾ÝÖ®ºó |
| | | |
| | | return SizhuV4ProtocolDataAnalysis((uint8_t *)buf_next_p,ack_buf,ack_buf_length); |
| | | |
| | | } |
| | |
| | | //?±ØÒªµÄͨѶ²ÎÊý³õʼ»¯¿ÉÒÔ·ÅÔÚÕâÀï |
| | | SizhuV4SendParaInit(); |
| | | |
| | | return WRC_SEND_DATA; |
| | | return WRC_CREATE_LINK; |
| | | } |
| | | |
| | | WRC_STATUS WrcCreateLinkPro(void) |
| | |
| | | // wrc_ctrl_para_g.time_out_cnt = wrc_ctrl_para_g.time_out_time_sec; |
| | | |
| | | send_buf[0] = WRC_MODULE_CMD_DATA_UP; |
| | | send_buf[1] = send_length &0x0f; |
| | | send_buf[1] = send_length &0xff; |
| | | send_buf[2] = send_length >>8; |
| | | |
| | | if(send_length > sizeof(send_buf)){ |
| | |
| | | return WRC_OFF; |
| | | } |
| | | |
| | | WRC_UART_SEND(send_buf,send_length); |
| | | WRC_UART_SEND(send_buf,send_length + 3); |
| | | |
| | | __SYS_DELAY_SEC_TIME_SET_(wrc_timeout_para,wrc_ctrl_para_g.time_out_time_sec); |
| | | |
| | |
| | | { |
| | | WRC_STATUS return_status; |
| | | uint8_t send_buf[3+1024] = {0}; |
| | | uint16_t send_length; |
| | | uint16_t send_length = 0; |
| | | |
| | | //½ÓÊÕbuf´¦Àí |
| | | WRC_RX_DMA_check(&wrc_uart_para_g); |
| | |
| | | |
| | | if((send_length > 0)&&(send_length < sizeof(send_buf))){ //ÓÐÏìÓ¦Êý¾ÝÐèÒª·¢ËÍ |
| | | send_buf[0] = WRC_MODULE_CMD_DATA_UP; |
| | | send_buf[1] = send_length &0x0f; |
| | | send_buf[1] = send_length &0xff; |
| | | send_buf[2] = send_length >>8; |
| | | WRC_UART_SEND(send_buf,send_length); |
| | | WRC_UART_SEND(send_buf,send_length + 3); |
| | | __SYS_DELAY_SEC_TIME_SET_(wrc_timeout_para,wrc_ctrl_para_g.time_out_time_sec); |
| | | } |
| | | memset(wrc_uart_para_g.recv_buf,0,sizeof(wrc_uart_para_g.recv_buf)); |
| | |
| | | |
| | | //»ñÈ¡²»Í¬ÐÒéµÄͨѶ½á¹û |
| | | wrc_ctrl_para_g.wrc_result_flag = wrc_sizhuV4_result_flag; |
| | | wrc_ctrl_para_g.report_result_flag = (report_sizhuV4_result_flag == PASS)? PASS: wrc_ctrl_para_g.wrc_result_flag;//Ö»Óгɹ¦²Å¸Ä±ä״̬£¬·ñÔò±£³ÖÔÖµ |
| | | report_sizhuV4_result_flag = FAIL; |
| | | |
| | | wrc_ctrl_para_g.wrc_OFF_cnt ++; |
| | | |
| | |
| | | PWR_3V8_OFF; |
| | | return WRC_OFF; |
| | | |
| | | }else if(wrc_ctrl_para_g.wrc_OFF_cnt == 8){ |
| | | }else if(wrc_ctrl_para_g.wrc_OFF_cnt >= 8){ |
| | | //ÑÓ³ÙÍ˳öͨѶÁ÷³Ì£¬´ËʱµçÔ´ÒѾ¹Ø±Õ£¬Ï൱ÓÚ¸øµçÈÝÒ»¶¨Ê±¼ä³äµç |
| | | WRC_PWR_OFF; |
| | | PWR_3V8_OFF; |
| | |
| | | return WRC_IDLE; //¹Ø»úÍê±Ï£¬·µ»ØWRC_IDLE½áÊø±¾´ÎͨѶÁ÷³Ì |
| | | } |
| | | |
| | | return WRC_IDLE; |
| | | return WRC_OFF; |
| | | } |
| | | |
| | | |
| | | //¶àÌìδÉϱ¨³É¹¦Åжϣ¬Åжϱê×¼¿ÉÒÔ±ÈͨѶÊÇ·ñ³É¹¦¿íËÉÒ»µã£¬Ö»ÒªÊý¾ÝÓÐÉϱ¨ÏìÓ¦¼´¿ÉÅжϳɹ¦£¬µ¥Ö¡Êý¾ÝÎÞÏìÓ¦µÄÓýáÊøÖ¡»òÕ߯äËûÖ¡´ú±í³É¹¦ |
| | | void LongTimeReportFailed(BILLING_VALVE_CTRL_PATA_T billing_valve_ctrl_para_in) |
| | | { |
| | | static uint8_t report_failed_days_cnt = 0; |
| | | //ÒòΪ´ó²¿·Ö±í0µãÖ®ºó»áÓÐÒ»´ÎͨѶ£¬ÄÇôÅжÏʱ¼äµã¿ÉÒÔÑÓºóµ½ÔçÉÏ6µã55ÅÐ¶Ï |
| | | if((&sys_clockBCD_g)->hour == 6 && (&sys_clockBCD_g)->min == 55 && (&sys_clockBCD_g)->sec == 0 ){ |
| | | if(billing_valve_ctrl_para_in.no_wrc_days > 0){ //´óÓÚ0´ú±í¹¦ÄÜ¿ªÆô |
| | | if(wrc_ctrl_para_g.report_result_flag == PASS){ |
| | | report_failed_days_cnt = 0; |
| | | __SYS_STATUS_BYTES_STATUS(no_gprs_date_up_to, RESET, ALARM_ID_N_DAYS_NO_REPORT_ARRIVE); |
| | | }else{ |
| | | if((report_failed_days_cnt++) >= billing_valve_ctrl_para_in.no_wrc_days){ //ºó++ÊÇÒòΪµÚÒ»´ÎÅжÏʱ²»Âú1Ìì |
| | | __SYS_STATUS_ALARM_BYTES_SET(no_gprs_date_up_to,ALARM_ID_N_DAYS_NO_REPORT_ARRIVE); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | void WirelessRemoteCommPro(FUN_START_CTRL_PARA_T * sys_fun_run_ctrl_p) |
| | |
| | | else |
| | | sys_fun_run_ctrl_p->wrc_ctrl_flag.running_flag = SET; |
| | | |
| | | |
| | | //¶àÌìδÉϱ¨³É¹¦Åжϣ¬²»Í¬ÐÒéÅжϵıê×¼²»Í¬ |
| | | LongTimeReportFailed(billing_valve_ctrl_para_g); |
| | | |
| | | |
| | | } |
| | | |