0001+1=0002

package com.xcfh.util;

import com.xcfh.util.IntDigitPadded;

/**
 * 
 * @ClassName: IntDigitPadded
 * 
 * @Description: 数字位数补齐,如果此数小于定义总位数,则前面补零
 * @author PineTree
 * @date 2014年12月19日 下午3:57:38
 * @version
 */
public class IntDigitPadded {
    
    /**
     * 如果数字相加(减)后的值小于定义的数字总长度时前面补零
     * 
     * @param i int类型i
     * @param j int类型j
     * @param digits 数字总位数
     * 如:0001 + 1 = 0002;digits值为4
     * 如:01 + 1 = 02;digits值为2
     * digits值是根据你的数字总长度来决定 
     * @return
     */
    public static String formatNum(int i, int j, int digits){
        //String.format("%0 + 总位数 + d", 数字1 + 数字2)
        return String.format("%0" + digits + "d", i + j);
    }
    
    /**
     * 如果数字位数小于定义总长度,前面补零
     * 
     * @param i 需要补齐的数字
     * @param digits 数字总位数
     * @return String
     */
    public static String formatNumber(int i, int digits) {
        //String.format("%0 + 总位数 + d", 需转换数字)
        return  String.format("%0" + digits + "d", i);
    }
    
    /**
     * 获取X-Y之间的数字,如果X-Y之间小于定义总长度,那么此数字前用零补齐
     * 
     * @param startNum 开始数字
     * @param EndNum 结束数字
     * @return String[]
     */
    public static String[] formatNumbers(int startNum,int EndNum, int digits){
        int len = (EndNum - startNum) + 1; // 获取要循环的数组长度
        System.out.println("length = " + len);
        String[] numbers = new String[len];
        String str = ""; // 第i个数值
        for(int i = 0; i < len; i++){
            System.out.println("i = " + i);
            str = String.format("%0" + digits + "d", startNum++);
            System.out.println(str);
            numbers[i] = str;
        }
        return numbers;
    }
}
#include"string.h" #include"usersys.h" #include"userpar.h" #include"useruart.h" #include"usersram.h" #include"useruart_exter.h" #include"usart.h" #include "update_fpga_gw2a.h" #define ACK_RS422 1 #define ACK_NET 2 #define host_cmd_0 0x00 #define host_cmd_1 0x01 #define host_cmd_2 0x02 #define host_cmd_3 0x03 #define host_cmd_4 0x04 #define host_cmd_5 0x05 #define host_cmd_F 0x0F #define sub_cmd_0 0x00 #define sub_cmd_1 0x01 #define sub_cmd_2 0x02 #define sub_cmd_3 0x03 #define sub_cmd_4 0x04 #define sub_cmd_5 0x05 #define sub_cmd_6 0x06 #define sub_cmd_7 0x07 #define sub_cmd_8 0x08 #define sub_cmd_9 0x09 #define sub_cmd_a 0x0a #define sub_cmd_b 0x0b #define sub_cmd_c 0x0c #define sub_cmd_d 0x0d #define sub_cmd_e 0x0e #define sub_cmd_f 0x0f #define sub_cmd_10 0x10 #define sub_cmd_11 0x11 #define sub_cmd_12 0x12 #define sub_cmd_13 0x13 #define sub_cmd_14 0x14 #define sub_cmd_f1 0xf1 #define sub_cmd_f2 0xf2 #define cmd_update_read_par_ack 0x64//¶Á²ÎÊýÓ¦´ðÖ¸Áî #define cmd_update_write_par 0x63//д²ÎÊýÖ¸Áî #define cmd_update_read_par 0x61//¶Á²ÎÊýÖ¸Áî #define cmd_update_write_par_ack 0x60//д²ÎÊýÓ¦´ðÖ¸Áî uartPro_Typedef uartPro_422,uartPro_net; uartPro_Typedef uartPro_com; #define EXTER_UARTRXFRAMELEN 9 #define UART_EXTER_FRAME_HEAD 0XA0 #define EXTER_UARTRXFRAMELEN_UPDATE 1100 void useruart_exter_Init(void) { uartPro_422.buf_full = FALSE; uartPro_net.buf_full = FALSE; HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_SET); } void useruart_exter_NetRx(uint8_t tmp) { uint8_t i = 0; if(userpar_Get_workmode() == uddate_work_mode) { uartPro_net.rxDsp_Buf[uartPro_net.rx_len++]=tmp; UserTimer_SetPeroid(TIMER_NET_IDLE_PERIOD,TIMER_NET_IDLE_OPT); if(uartPro_net.rx_len >= EXTER_UARTRXFRAMELEN_UPDATE) { uartPro_net.rx_len = 0; } } else { for(i = 0;i < (EXTER_UARTRXFRAMELEN-1);i++) { uartPro_net.rxDsp_Buf[i] = uartPro_net.rxDsp_Buf[i+1]; } uartPro_net.rxDsp_Buf[EXTER_UARTRXFRAMELEN-1]=tmp; if((uartPro_net.rxDsp_Buf[EXTER_UARTRXFRAMELEN-1] == UARTFRAMEEND) && (uartPro_net.rxDsp_Buf[0] == UARTFRAMEHEAD)) { uartPro_net.buf_full = TRUE; } } } void useruart_Rs422Rx(uint8_t tmp) { uint8_t i = 0; if(userpar_Get_workmode() == uddate_work_mode) { uartPro_422.rxDsp_Buf[uartPro_422.rx_len++]=tmp; UserTimer_SetPeroid(TIMER_RS422_IDLE_PERIOD,TIMER_RS422_IDLE_OPT); if(uartPro_422.rx_len >= EXTER_UARTRXFRAMELEN_UPDATE) { uartPro_422.rx_len = 0; } } else { for(i = 0;i < (EXTER_UARTRXFRAMELEN-1);i++) { uartPro_422.rxDsp_Buf[i] = uartPro_422.rxDsp_Buf[i+1]; } uartPro_422.rxDsp_Buf[EXTER_UARTRXFRAMELEN-1]=tmp; if((uartPro_422.rxDsp_Buf[EXTER_UARTRXFRAMELEN-1] == UARTFRAMEEND) && (uartPro_422.rxDsp_Buf[0] == UARTFRAMEHEAD)) { uartPro_422.buf_full = TRUE; } } } unsigned short CRC16_MODBUS(unsigned char *ptr, int len) { unsigned int i; unsigned short crc = 0xFFFF; while(len--) { crc ^= *ptr++; for (i = 0; i < 8; ++i) { if (crc & 1) crc = (crc >> 1) ^ 0xA001; else crc = (crc >> 1); } } return crc; } #define MCU__UPDATE_DST_ID 0x0001 #define FPGA_UPDATE_DST_ID 0x0002 #define PACK_BYTES_LEN 1000 uint32_t now_pack_cnt; uint32_t pack_bytes = 0; void useruart_exter_Handle_Update_Commun(void) { uint8_t now_ack = ACK_RS422; // uint8_t checksum = 0,i; // uint8_t now_ack = ACK_RS422; uint8_t *pBuf = uartPro_com.rxDsp_Buf; // uint32_t RegValue; uint16_t nowCalCRC,nowRxCRC; uint16_t src_id,dst_id; uint16_t now___pack_num,total_pack_num; uint32_t len; if(UserTimer_InqIsTrigger(TIMER_NET_IDLE_OPT) == TRUE) { memcpy(uartPro_com.rxDsp_Buf,uartPro_net.rxDsp_Buf,uartPro_net.rx_len); uartPro_com.buf_full = TRUE; uartPro_com.rx_len = uartPro_net.rx_len; uartPro_net.rx_len = 0; now_ack = ACK_NET; } else if(UserTimer_InqIsTrigger(TIMER_RS422_IDLE_OPT) == TRUE) { memcpy(uartPro_com.rxDsp_Buf,uartPro_422.rxDsp_Buf,uartPro_422.rx_len); uartPro_com.buf_full = TRUE; uartPro_com.rx_len = uartPro_422.rx_len; uartPro_422.rx_len = 0; now_ack = ACK_RS422; } else { uartPro_com.buf_full = FALSE; } if(uartPro_com.buf_full == TRUE) { if(uartPro_com.rx_len > 2) { nowCalCRC = CRC16_MODBUS(pBuf,uartPro_com.rx_len-2); } nowRxCRC = (unsigned short)(pBuf[uartPro_com.rx_len-2] << 8) + (unsigned short)(pBuf[uartPro_com.rx_len-1] << 0); len = (pBuf[2] << 8) + (pBuf[3] << 0); src_id = (pBuf[4] << 8) + (pBuf[5] << 0); dst_id = (pBuf[6] << 8) + (pBuf[7] << 0); now___pack_num = (pBuf[10] << 8) + (pBuf[11] << 0); total_pack_num = (pBuf[12] << 8) + (pBuf[13] << 0); if((pBuf[0] == UART_EXTER_FRAME_HEAD) && (nowCalCRC == nowRxCRC) && (len == (uartPro_com.rx_len-4))) { uartPro_com.tx_len = 0; uartPro_com.tx_buf[uartPro_com.tx_len++] = UART_EXTER_FRAME_HEAD; switch(pBuf[1]) { // case cmd_update_read_par: // // break; case cmd_update_write_par: uartPro_com.tx_buf[uartPro_com.tx_len++] = cmd_update_write_par_ack; uartPro_com.tx_buf[uartPro_com.tx_len++] = 0; uartPro_com.tx_buf[uartPro_com.tx_len++] = 0; switch(pBuf[8]) { case host_cmd_0: switch(pBuf[9]) { case sub_cmd_1://ÎÕÊÖ uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[8]; uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[9]; uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x00; if(dst_id == MCU__UPDATE_DST_ID) { userpar_Erase_mcu_update_pack(); } else if(dst_id == FPGA_UPDATE_DST_ID) { //SRAM¿ÉÒÔ²»²Á³ý } now_pack_cnt = 0; pack_bytes = 0; break; case sub_cmd_2://Éý&frac14;¶°ü now_pack_cnt++; uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[8]; uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[9]; if(now_pack_cnt != now___pack_num) { uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x02; } else { if(now___pack_num > total_pack_num) { uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x01; } else { uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x00; if(dst_id == MCU__UPDATE_DST_ID) { userpar_write_mcu_update_pack(uartPro_com.rx_len-16,(uint8_t*)&pBuf[14],(now___pack_num-1) * PACK_BYTES_LEN); } else if(dst_id == FPGA_UPDATE_DST_ID) { usersram_write_data(&pBuf[14], uartPro_com.rx_len-16,base_addr_sram + PACK_BYTES_LEN*(now___pack_num-1)); } pack_bytes = pack_bytes + uartPro_com.rx_len-16; } } break; case sub_cmd_3://ÕûÌåУÑé sha256 uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[8]; uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[9]; if(dst_id == MCU__UPDATE_DST_ID) { userpar_write_mcu_update_bytes(pack_bytes,MCU_UPDATE_PACK_LEN_OFFSET_ADDR);//Ò»¶¨Ê&sup1;Óà userpar_write_mcu_update_flag_write(MCU_UPDATE_FLAG_OFFSET_ADDR,MCU_UPDATE_FLAG); uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x00; //userpar_update_trig_warn_state(1); } else if(dst_id == FPGA_UPDATE_DST_ID) { //userpar_trig_fpga_jtag_update(); usersram_write_size(pack_bytes);//Ò»¶¨Ê&sup1;Óà if(user_update_fpga_gw2a() == TRUE) { uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x00; } else { uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x01; } // userpar_update_trig_warn_state(1); } break; } break; } break; default: uartPro_com.tx_buf[uartPro_com.tx_len++] = cmd_update_write_par_ack; uartPro_com.tx_buf[uartPro_com.tx_len++] = 0; uartPro_com.tx_buf[uartPro_com.tx_len++] = 0; uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[8]; uartPro_com.tx_buf[uartPro_com.tx_len++] = pBuf[9]; uartPro_com.tx_buf[uartPro_com.tx_len++] = 0x05; break; } uartPro_com.tx_buf[2] = 0;// - 2; uartPro_com.tx_buf[3] = uartPro_com.tx_len-2; nowCalCRC = CRC16_MODBUS(uartPro_com.tx_buf,uartPro_com.tx_len); uartPro_com.tx_buf[uartPro_com.tx_len++] = (nowCalCRC >> 8) & 0xff; uartPro_com.tx_buf[uartPro_com.tx_len++] = (nowCalCRC >> 0) & 0xff; if(now_ack == ACK_RS422) { HAL_UART_Transmit(&USART_RS422_USER,uartPro_com.tx_buf,uartPro_com.tx_len,1000); } else { HAL_UART_Transmit(&USART_NET_USER,uartPro_com.tx_buf,uartPro_com.tx_len,1000); } } uartPro_com.rx_len = 0; uartPro_com.buf_full = FALSE; } } void useruart_exter_Handle_Normal_Commun(void) { uint8_t checksum = 0,i; uint8_t now_ack = ACK_RS422; uint8_t *pBuf = NULL; uint32_t tmp; uint8_t *pcal; if((uartPro_422.buf_full == TRUE) || (uartPro_net.buf_full == TRUE)) { if(uartPro_422.buf_full == TRUE) { pBuf = uartPro_422.rxDsp_Buf; now_ack = ACK_RS422; } else if(uartPro_net.buf_full == TRUE) { pBuf = uartPro_net.rxDsp_Buf; now_ack = ACK_NET; } uartPro_422.buf_full = FALSE; uartPro_net.buf_full = FALSE; for(i = 1;i < (EXTER_UARTRXFRAMELEN-2);i++) { checksum = checksum + pBuf[i]; } if(checksum != pBuf[EXTER_UARTRXFRAMELEN-2]) { return; } uartPro_422.tx_len = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = UARTFRAMEHEAD; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[1]; switch(pBuf[1]) { case cmd01: userpar_SetPACtl_Soft(pBuf[6]); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd06: userpar_SetPAAtt_Soft(pBuf[6]); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd0F: uartPro_net.rx_len = 0; uartPro_422.rx_len = 0; userpar_Set_workmode(pBuf[6]); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd81: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = userpar_GetPACtl_Soft(); break; case cmd86: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = userpar_GetPAAtt_Soft(); break; case cmd82: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; tmp = userpar_GetRD_Power(); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 8) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 0) & 0xff); tmp = userpar_GetFD_Power(); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 8) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 0) & 0xff); break; case cmd83: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; tmp = userpar_GetPA_Vol(); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 8) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 0) & 0xff); tmp = userpar_GetPA_Curr(); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 8) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 0) & 0xff); break; case cmd84: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = userpar_GetPA_State(); uartPro_422.tx_buf[uartPro_422.tx_len++] = userpar_GetTemp(); break; case cmd85: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; uartPro_422.tx_buf[uartPro_422.tx_len++] = userpar_GetFun1_Curr(); uartPro_422.tx_buf[uartPro_422.tx_len++] = userpar_GetFun2_Curr(); break; case cmd0A: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; tmp = (pBuf[3] << 24) | (pBuf[4] << 16) | (pBuf[5] << 8) | pBuf[6] ; userpar_SetFreq(tmp); tmp = userpar_GetFreq(); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 24) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 16) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 8) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 0) & 0xff); break; case cmd8A: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; tmp = userpar_GetFreq(); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 24) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 16) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 8) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 0) & 0xff); break; case cmd71://ͨµÀ1ÊäÈë&sup1;¦ÂÊ pcal = userpar_correct_detectvol_inputpower_ch1(pBuf[2]); memcpy(pcal,(uint8_t*)&pBuf[3],4); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd72://ͨµÀ1Êä³ö&sup1;¦ÂÊ pcal = userpar_correct_detectvol_outputpower_ch1(pBuf[2]); memcpy(pcal,(uint8_t*)&pBuf[3],4); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd73://ͨµÀ1ÊäÈë&sup1;¦ÂÊ userpar_SavePower_vol(); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd74://ͨµÀ1ÕýÏò&sup1;¦ÂÊÃÅÏÞ pcal = userpar_correct_ch1_jb_fd_power(); memcpy(pcal,(uint8_t*)&pBuf[3],4); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd75://ͨµÀ1פ²¨²îÖµ pcal = userpar_correct_ch1_jb_dlt(); memcpy(pcal,(uint8_t*)&pBuf[3],4); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmd76://ͨµÀ1פ²¨²îÖµ userpar_Save_swrPar(); uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[2]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[3]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[4]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[5]; uartPro_422.tx_buf[uartPro_422.tx_len++] = pBuf[6]; break; case cmdF1://ͨµÀ1ÊäÈë&sup1;¦ÂÊ uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; pcal = userpar_correct_detectvol_inputpower_ch1(pBuf[2]); memcpy((uint8_t*)&uartPro_422.tx_buf[uartPro_422.tx_len],pcal,4); uartPro_422.tx_len = uartPro_422.tx_len + 4; break; case cmdF2://ͨµÀ1Êä³ö&sup1;¦ÂÊ uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; pcal = userpar_correct_detectvol_outputpower_ch1(pBuf[2]); memcpy((uint8_t*)&uartPro_422.tx_buf[uartPro_422.tx_len],pcal,4); uartPro_422.tx_len = uartPro_422.tx_len + 4; break; case cmdF4://ͨµÀ1ÕýÏò&sup1;¦ÂÊÃÅÏÞ uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; pcal = userpar_correct_ch1_jb_fd_power(); memcpy((uint8_t*)&uartPro_422.tx_buf[uartPro_422.tx_len],pcal,4); uartPro_422.tx_len = uartPro_422.tx_len + 4; break; case cmdF5://ͨµÀ1פ²¨²îÖµ uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; pcal = userpar_correct_ch1_jb_dlt(); memcpy((uint8_t*)&uartPro_422.tx_buf[uartPro_422.tx_len],pcal,4); uartPro_422.tx_len = uartPro_422.tx_len + 4; break; // case cmdFA://ͨµÀ1ÊäÈë&frac14;첨µçÑ&sup1; // uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; // pcal = userpar_advol_input_ch1(); // memcpy((uint8_t*)&uartPro_422.tx_buf[uartPro_422.tx_len],pcal,4); // uartPro_422.tx_len = uartPro_422.tx_len + 4; // break; case cmdFB://ͨµÀ1Êä³ö&frac14;첨µçÑ&sup1; uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; pcal = userpar_advol_output_ch1(); memcpy((uint8_t*)&uartPro_422.tx_buf[uartPro_422.tx_len],pcal,4); uartPro_422.tx_len = uartPro_422.tx_len + 4; break; case cmd8F: uartPro_422.tx_buf[uartPro_422.tx_len++] = 0; tmp = userpar_get_pa_run_timer_1s(); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 24) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 16) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 8) & 0xff); uartPro_422.tx_buf[uartPro_422.tx_len++] = ((tmp >> 0) & 0xff); break; default: break; } checksum = 0; for(i = 1;i < uartPro_422.tx_len;i++) { checksum = checksum + uartPro_422.tx_buf[i]; } uartPro_422.tx_buf[uartPro_422.tx_len++] = checksum; uartPro_422.tx_buf[uartPro_422.tx_len++] = UARTFRAMEEND; if(now_ack == ACK_RS422) { HAL_UART_Transmit(&USART_RS422_USER,uartPro_422.tx_buf,uartPro_422.tx_len,1000); } else { HAL_UART_Transmit(&USART_NET_USER,uartPro_422.tx_buf,uartPro_422.tx_len,1000); } } } void useruart_exter_Handle(void) { if(userpar_Get_workmode() == normal_work_mode) { useruart_exter_Handle_Normal_Commun(); } else { useruart_exter_Handle_Update_Commun(); } }
最新发布
11-14
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值