| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648 |
- /*
- * uart_rcv.c
- *
- * Created on: 2022年4月20日
- * Author: dell
- */
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include "NuMicro.h"
- #include "cfg_param_record.h"
- #include "uart_rcv.h"
- #include "usr_pid.h"
- #include "cJSON.h"
- #include "ws2812.h"
- #define ENV_ADJ_THRESHOLD 27.0
- enum SLAVE_MCU_Ctr_cmd_type
- {
- SLAVE_MCU_CMD_PARAM = 0x01,
- SLAVE_MCU_CMD_HEAT = 0x02,
- SLAVE_MCU_CMD_LIGHT_CTR= 0X03,
- SLAVE_MCU_CMD_QRSCANNER_CTR= 0X04,
- SLAVE_MCU_CMD_FAN= 0X05,
- SLAVE_MCU_CMD_CARD_ST= 0X06,
- SLAVE_MCU_CMD_PID = 0x20,
- };
- enum SLAVE_MCU_Ctr_UP_type
- {
- SLAVE_MCU_UP_HEAT = 0x10,
- SLAVE_MCU_UP_QR_PARAM= 0X11,
- SLAVE_MCU_UP_QR = 0x12,
- SLAVE_MCU_INFO, //异常信息
- };
- #define combine_cmdMessage(msg,header,seqer,cmder,tailer) { \
- msg.head = header; \
- msg.seq = seqer; \
- msg.cmd = cmder; \
- msg.tail = tailer; \
- }
- uint8_t g_uart2_rcv_start = 0;
- uint8_t g_uart2_rcv_complete_flg = 0;
- uint16_t g_uart2_rx_len = 0;
- uint8_t g_uart2_frame_overtime_cnt = 0;
- uint16_t g_uart2_rcv_cmd = 0;
- uint16_t g_uart2_cmd_overtime_secs = 0;
- uint32_t g_uart2_cmd_overtime_cnt = 0;
- uint8_t g_param_set_mode = 0; // 参数设置模式
- uint8_t g_uart1_rcv_start = 0;
- uint8_t g_uart1_rcv_complete_flg = 0;
- uint8_t g_uart1_tx_buf[BUF_SIZE] = {0};
- uint8_t g_uart1_rx_buf[BUF_SIZE] = {0};
- uint8_t g_uart1_rx_len = 0;
- uint8_t g_uart1_frame_overtime_cnt = 0;
- uint8_t g_uart0_rcv_start = 0;
- uint8_t g_uart0_rcv_complete_flg = 0;
- uint8_t g_uart0_tx_buf[DEBUG_BUF_SIZE] = {0};
- uint8_t g_uart0_rx_buf[BUF_SIZE] = {0};
- uint8_t g_uart0_rx_len = 0;
- uint8_t g_uart0_frame_overtime_cnt = 0;
- uint32_t uart0_header = 0;
- uint32_t uart0_last = 0;
- unsigned int haveheaderflag = 0;
- heat_ctrl_struct g_heat_ctrl = {0};
- // card_param_struct card = {0};
- str_hole_info_t hole1 = {0};
- str_hole_info_t hole2 = {0};
- str_hole_info_t hole3 = {0};
- str_hole_info_t hole4 = {0};
- str_hole_info_t hole5 = {0};
- str_hole_info_t hole6 = {0};
- str_hole_info_t hole7 = {0};
- str_hole_info_t hole8 = {0};
- str_hole_info_t hole9 = {0};
- str_hole_info_t hole10 = {0};
- str_card_param_info_t m_str_card_param_info = {0};
- uint32_t qr_check_delay = QR_CHECH_STATE_FIRST; /*1s定时器里面,大于0,每s减1*/
- extern void QRparam_upload(str_card_param_info_t *p_str_card_param_info);
- extern uint8_t sys_info[40];
- /********************************************************************
- * bcd_to_hex()
- *
- *描述:BCD转HEX
- *参数:无
- *返回:无
- *其他:无
- *--------------------------------------------------------------------
- *记录:
- ********************************************************************/
- uint8_t bcd_to_hex(uint8_t val)
- {
- return ((val / 10) << 4) + val % 10;
- }
- /********************************************************************
- * debug_receive_int_handle()
- *
- *描述:调试串口接收中断数据处理
- *参数:无
- *返回:无
- *其他:无
- *--------------------------------------------------------------------
- *记录:
- ********************************************************************/
- void debug_receive_int_handle0(void)
- {
- if (UART_GET_INT_FLAG(UART0, UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk))
- {
- /* UART receive data available flag */
- /* Move the data from Rx FIFO to sw buffer (RAM). */
- /* Every time leave 1 byte data in FIFO for Rx timeout */
- while (UART_GET_RX_EMPTY(UART0) == 0)
- {
- if (uart0_last == BUF_SIZE)uart0_last = 0;
- g_uart0_rx_buf[uart0_last] = UART_READ(UART0);
- uart0_last++;
- }
- }
- }
- void debug_receive_int_handle1(void)
- {
- while (UART_GET_RX_EMPTY(UART1) == 0)
- {
- if (g_uart1_rx_len >= BUF_SIZE)
- g_uart1_rx_len = 0;
- g_uart1_rx_buf[g_uart1_rx_len] = UART_READ(UART1);
- g_uart1_rx_len++;
- }
- }
- /********************************************************************
- * UART02_IRQHandler()
- *
- *描述:串口接收中断
- *参数:无
- *返回:无
- *其他:无
- *--------------------------------------------------------------------
- *记录:
- ********************************************************************/
- void UART02_IRQHandler(void)
- {
- if (UART_GET_INT_FLAG(UART0, UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk | UART_INTSTS_RXTOIF_Msk) )
- {
- debug_receive_int_handle0();
- }
- else if (UART_GET_INT_FLAG(UART0,UART_INTSTS_BUFERRIF_Msk) )
- {
- debug_receive_int_handle0();
- UART_ClearIntFlag(UART0,UART_INTSTS_BUFERRINT_Msk);
- }
- else if (UART_GET_INT_FLAG(UART0,UART_INTSTS_RLSINT_Msk) )
- {
- UART_ClearIntFlag(UART0,UART_INTSTS_RLSINT_Msk);
- }
-
- if (UART_GET_INT_FLAG(UART2, UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk | UART_INTSTS_RXTOIF_Msk) )
- {
- debug_receive_int_handle2();
- }
- else if (UART_GET_INT_FLAG(UART2,UART_INTSTS_BUFERRIF_Msk) )
- {
- debug_receive_int_handle2();
- UART_ClearIntFlag(UART2,UART_INTSTS_BUFERRINT_Msk);
- }
- else if (UART_GET_INT_FLAG(UART2,UART_INTSTS_RLSINT_Msk) )
- {
- UART_ClearIntFlag(UART2,UART_INTSTS_RLSINT_Msk);
- }
- }
- /********************************************************************
- * UART13_IRQHandler()
- *
- *描述:串口接收中断
- *参数:无
- *返回:无
- *其他:无
- *--------------------------------------------------------------------
- *记录:
- ********************************************************************/
- void UART13_IRQHandler(void)
- {
- if (UART_GET_INT_FLAG(UART1, UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk | UART_INTSTS_RXTOIF_Msk) )
- {
- debug_receive_int_handle1();
- }
- else if (UART_GET_INT_FLAG(UART1,UART_INTSTS_BUFERRIF_Msk) )
- {
- debug_receive_int_handle1();
- UART_ClearIntFlag(UART1,UART_INTSTS_BUFERRINT_Msk);
- }
- else if (UART_GET_INT_FLAG(UART1,UART_INTSTS_RLSINT_Msk) )
- {
- UART_ClearIntFlag(UART1,UART_INTSTS_RLSINT_Msk);
- }
- }
- void sendMsgtoMasterMcu(struct CmdMessage *pmsg)
- {
- static uint8_t sedbuf[DEBUG_BUF_SIZE];
- uint16_t checksum = 0;
- *(unsigned short *)sedbuf = pmsg->head;
- sedbuf[2] = pmsg->seq;
- sedbuf[3] = pmsg->cmd;
- *(unsigned short *)(sedbuf+4) = pmsg->len;
- for(int i=0; i < pmsg->len; i++){
- sedbuf[6+i] = pmsg->data[i];
- }
- for(int i=2; i < (pmsg->len + 6); i++){
- checksum += sedbuf[i];
- }
- sedbuf[6+pmsg->len] = checksum&0xff;/*结尾标记高位*/
- sedbuf[7+pmsg->len ] = checksum>>8 ;/*结尾标记低位*/
- UART_Write(UART0, sedbuf, (8+pmsg->len));
- }
- uint16_t checkSum(const uint8_t *pInBuffer, int uLen)
- {
- uint32_t sum = 0;
- for(int i = 0; i < uLen; i++)
- {
- sum += pInBuffer[i];
- }
- return (sum);
- }
- /********************************************************************
- * int Decode(const char *pInBuffer, int uLen)
- *
- *描述:对串口数据进行解码成结构体
- *参数:pInBuffer 接收缓冲区
- *uheader 当前头位置
- ulast 当前头尾位置
- maxlen 缓冲区长度
- pMessage 命令结构体
- pdata 命令数据
- *返回:1解码成功,0解码失败
- *其他:无
- *--------------------------------------------------------------------
- *记录:
- ********************************************************************/
- int DecodeNew(struct CmdMessage *pMessage, uint8_t *pdata, const uint8_t *pInBuffer, uint32_t* pheader,uint32_t ulast,uint32_t maxlen)
- {
- uint32_t bufRealLen;
- uint32_t sizeofMessage = MINI7_MASSAGE_SIZE;
- uint32_t header = *pheader;
- uint32_t i = 0;
- if (NULL == pInBuffer || NULL == pMessage || NULL == pdata || NULL == pheader)
- {
- /*空指针判断*/
- return 0;
- }
- /*缓冲区有效数据长度,缓冲区循环处理,会出现头大于未情况*/
- bufRealLen = (ulast > header)?(ulast - header):(ulast + maxlen - header);
- if(bufRealLen < sizeofMessage){
- /*长度过段,跳过*/
- return 0;
- }
- bufRealLen -= sizeofMessage; /*最大有效数据长度*/
- for(; i<=bufRealLen;){
- uint32_t headerflag = pInBuffer[(header + i)%maxlen];
- headerflag += pInBuffer[(header + i + 1)%maxlen] <<8;
- if(headerflag != MINI7_HEADER_FALG){
- i += 1;
- // header = (header + 1)%maxlen;
- continue;
- }
- uint32_t messagelen = pInBuffer[(header + i + 4)%maxlen];
- messagelen += pInBuffer[(header + i + 5)%maxlen] <<8;
- if(messagelen > (maxlen- sizeofMessage)){
- /*长度超长 跳过2个字节*/
- i += 1;
- // header = (header + 1)%maxlen;
- continue;
- }
- if(messagelen >bufRealLen){
- /*当前起始点可能存在数据,跳出循环,*/
- i++; /*for采样小于等于判断,循环次数多1,此处加1便于后续处理*/
- break;
- }
- uint16_t checkesum = 0;
- uint16_t recsum = 0;
- if((header + i + 6 + messagelen) < maxlen){
- checkesum = checkSum(pInBuffer + header + i + 2, messagelen+4);
- }else{
- checkesum = checkSum(pInBuffer + header + i + 2, (maxlen - (header + i + 2)));
- checkesum += checkSum(pInBuffer, (header + i + 6 + messagelen)%maxlen);
- }
- recsum = *(pInBuffer + (header + i + 6 + messagelen)%maxlen ) ;
- recsum += *(pInBuffer + (header + i + 7 + messagelen)%maxlen) << 8;
- /*固定结尾预留做调试用*/
- if(checkesum != recsum && recsum>>8 != MINI7_TAIL_FALG){
- i += 1;
- // ? ? ? ? ?header = (header + 1)%maxlen;
- }else{
- /*解析成功,拷贝消息结构体*/
- uint8_t * pCharMessage = (uint8_t *)pMessage;
- for(unsigned copyi=0;copyi<(sizeofMessage-2);copyi++){
- *pCharMessage++ = pInBuffer[(header + i+ copyi)%maxlen];
- }
- (*pMessage).tail = MINI7_TAIL_FALG;
- /*解析成功,拷贝数据结构体*/
- for(unsigned copyi=0;copyi<messagelen;copyi++){
- *pdata++ = pInBuffer[(header + i + 6 + copyi)%maxlen];
- }
- *pheader = (header + messagelen + i + sizeofMessage - 2)%maxlen;
- return 1;
- }
- }
- *pheader = (header + i - 1)%maxlen;
- return 0;
- }
- /********************************************************************
- * heater_state_upload()
- *
- *描述:上传加热、风扇状态及加热体温度
- *参数:无
- *返回:0/1:设置失败/成功
- *其他:无
- *--------------------------------------------------------------------
- *记录:包含上报和应答处理
- ********************************************************************/
- void heater_state_upload(uint32_t upenv)
- {
- struct CmdMessage msg;
- uint8_t databuf[7]={0};
- combine_cmdMessage(msg,MINI7_HEADER_FALG,MINI7_MASSAGE_TYPE_MCUTOMCU,SLAVE_MCU_UP_HEAT,MINI7_TAIL_FALG)
- if(upenv){
- msg.len = sizeof(databuf);
- }else{
- msg.len = sizeof(databuf)-2;
- }
- msg.data = databuf;
- databuf[0] = g_heat_ctrl.heat_state;
- databuf[1] = g_heat_ctrl.temp_stable_sta;
- databuf[2] = (uint8_t)pid1.ActualTemp;
- databuf[3] = (uint8_t)((pid1.ActualTemp - (uint8_t)pid1.ActualTemp) * 100);
- databuf[4] = g_heat_ctrl.fan_state;
- databuf[5] = (uint8_t)pid1.cabinTem;
- databuf[6] = (uint8_t)((pid1.cabinTem - (uint8_t)pid1.cabinTem) * 100);
- sendMsgtoMasterMcu(&msg);
-
- }
- void sendInfoMasterMcu(uint8_t *data, uint16_t len)
- {
- struct CmdMessage msg;
- combine_cmdMessage(msg,MINI7_HEADER_FALG,MINI7_MASSAGE_TYPE_MCUTOMCU,SLAVE_MCU_INFO,MINI7_TAIL_FALG)
- msg.len = len;
- msg.data = data;
- sendMsgtoMasterMcu(&msg);
- }
- /********************************************************************
- * uart2_rcv_frame_analysis()
- *
- *描述:接收帧解析
- *参数:无
- *返回:无
- *其他:无
- *--------------------------------------------------------------------
- *记录:
- ********************************************************************/
- void send_param(void){
- struct CmdMessage msg;
- combine_cmdMessage(msg,MINI7_HEADER_FALG,MINI7_MASSAGE_TYPE_MCUTOMCU,SLAVE_MCU_UP_QR_PARAM,MINI7_TAIL_FALG)
- msg.len = sizeof(m_str_card_param_info);
- msg.data = (char*)&m_str_card_param_info;
- sendMsgtoMasterMcu(&msg);
- }
- /********************************************************************
- * trigmode_select_sensor()
- *
- *描述:切换为感应触发模式
- *参数:无
- *返回:0/1:设置失败/成功
- *其他:无
- *--------------------------------------------------------------------
- *记录:包含上报和应答处理
- ********************************************************************/
- void trigmode_select_sensor(void)
- {
- memset(g_uart2_tx_buf, 0, sizeof(g_uart2_tx_buf));
- // memset(g_uart2_rx_buf, 0, sizeof(g_uart2_rx_buf));
- g_uart2_tx_buf[0] = 0x7E; // 帧头
- g_uart2_tx_buf[1] = 0x00; // 帧头
- g_uart2_tx_buf[2] = 0x08; // 命令标识
- g_uart2_tx_buf[3] = 0x01; // 命令标识
- g_uart2_tx_buf[4] = 0x00;
- g_uart2_tx_buf[5] = 0x00;
- g_uart2_tx_buf[6] = 0xD7;
- // g_uart2_tx_buf[6] = 0xEF;
- g_uart2_tx_buf[7] = 0xAB;
- g_uart2_tx_buf[8] = 0xCD;
- UART_Write(UART2, g_uart2_tx_buf, 9);
- }
- /********************************************************************
- * data_out_oragin()
- *
- *描述:切换为原始数据输出
- *参数:无
- *返回:0/1:设置失败/成功
- *其他:无
- *--------------------------------------------------------------------
- *记录:包含上报和应答处理
- ********************************************************************/
- void data_out_original(void)
- {
- memset(g_uart2_tx_buf, 0, sizeof(g_uart2_tx_buf));
- g_uart2_tx_buf[0] = 0x7E; // 帧头
- g_uart2_tx_buf[1] = 0x00; // 帧头
- g_uart2_tx_buf[2] = 0x08; // 命令标识
- g_uart2_tx_buf[3] = 0x01; // 命令标识
- g_uart2_tx_buf[4] = 0x00;
- g_uart2_tx_buf[5] = 0x0D;
- // g_uart0_tx_buf[6] = 0xD7;
- g_uart2_tx_buf[6] = 0xCA;
- g_uart2_tx_buf[7] = 0xAB;
- g_uart2_tx_buf[8] = 0xCD;
- UART_Write(UART2, g_uart2_tx_buf, 9);
- HAL_Delay(100);
- }
- int parse_qrcode_info(str_card_param_info_t *info, char *qrcode_str)
- {
- int id = 0;
- double Tt = 0;
- double Tt1 = 0;
-
- if (info == 0)
- {
- return -1;
- }
- cJSON *root = cJSON_Parse(qrcode_str);
- if (root == NULL)
- { /*消息不合格*/
- return -1;
- }
- cJSON *item = cJSON_GetObjectItem(root, "p");
- if (item == NULL)
- { /*消息不合格*/
- cJSON_Delete(root);
- return -1;
- }
- char *pid = cJSON_GetStringValue(item);
- // printf("pid=%s \r\n", pid);
- memcpy(info->pid, pid, 10);
- item = cJSON_GetObjectItem(root, "t");
- if (item == NULL)
- { /*消息不合格*/
- cJSON_Delete(root);
- return -1;
- }
- double t = item->valuedouble;
- // printf("t=%f \r\n", t);
- info->temp[0] = (uint8_t)t;
- info->temp[1] = (uint8_t)((t -(uint8_t)t)* 100);
- // 获取数组item
- item = cJSON_GetObjectItem(root, "e");
- if (item == NULL)
- { /*消息不合格*/
- cJSON_Delete(root);
- return -1;
- }
- int test_arry_size = cJSON_GetArraySize(item);
- for (int i = 0; i < test_arry_size; i++)
- {
- // 打印数组里的所有item
- cJSON *sub_array = cJSON_GetArrayItem(item, i);
- cJSON *sub = cJSON_GetObjectItem(sub_array, "i");
- id = sub->valueint;
- // printf("id=%d \r\n", id);
- if(id > 0)
- {
- sub = cJSON_GetObjectItemCaseSensitive(sub_array, "T");
- Tt = sub->valuedouble;
- // printf("Tt=%f \r\n", Tt);
- sub = cJSON_GetObjectItemCaseSensitive(sub_array, "t");
- Tt1 = sub->valuedouble;
- // printf("Tt1=%f \r\n", Tt1);
- }
- else
- {
- Tt = 0;
- Tt1 = 0;
- }
- info->hole_info[i].item = id;
- info->hole_info[i].TtMax[0] = (uint8_t)Tt;
- info->hole_info[i].TtMax[1] = (uint8_t)((Tt -(uint8_t)Tt)* 100);
- info->hole_info[i].TtMin[0] = (uint8_t)Tt1;
- info->hole_info[i].TtMin[1] = (uint8_t)((Tt1 -(uint8_t)Tt1)* 100);
- }
- // 记得删除json
- cJSON_Delete(root);
- return 0;
- }
- /********************************************************************
- * QRparam_upload()
- *
- *描述:上传二维码扫码参数
- *参数:无
- *返回:无
- *其他:无
- *--------------------------------------------------------------------
- *记录:包含上报和应答处理
- ********************************************************************/
- void QRparam_upload(str_card_param_info_t *p_str_card_param_info)
- {
- memset(g_uart0_tx_buf, 0, sizeof(g_uart0_tx_buf));
- // int QR_param_pid = 0;
- // QR_param_pid = atoi(&m_str_card_param_info.pid[0]);
- g_uart0_tx_buf[0] = 0xAA; // 帧头
- g_uart0_tx_buf[1] = 0x55; // 帧头
- g_uart0_tx_buf[2] = 0x0A; // 命令标识
- g_uart0_tx_buf[3] = 0x11; // 命令标识
- #if 0
- /*卡盒编号*/
- g_uart0_tx_buf[4] = (uint8_t)m_str_card_param_info.pid[0] - 48;
- g_uart0_tx_buf[5] = (uint8_t)m_str_card_param_info.pid[1] - 48;
- g_uart0_tx_buf[6] = (uint8_t)m_str_card_param_info.pid[2] - 48;
- g_uart0_tx_buf[7] = (uint8_t)m_str_card_param_info.pid[3] - 48;
- g_uart0_tx_buf[8] = (uint8_t)m_str_card_param_info.pid[4] - 48;
- g_uart0_tx_buf[9] = (uint8_t)m_str_card_param_info.pid[5] - 48;
- /*卡槽工作温度(整数+小数)*/
- g_uart0_tx_buf[10] = (uint8_t)(m_str_card_param_info.temp);
- g_uart0_tx_buf[11] = (uint8_t)((m_str_card_param_info.temp-(uint8_t)(m_str_card_param_info.temp))*100);
- /*孔1检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[12] = (uint8_t)(m_str_card_param_info.hole_info[0].item);
- g_uart0_tx_buf[13] = (uint8_t)(m_str_card_param_info.hole_info[0].TtMax);
- g_uart0_tx_buf[14] = (uint8_t)((m_str_card_param_info.hole_info[0].TtMax-(uint8_t)(m_str_card_param_info.hole_info[0].TtMax))*100);
- g_uart0_tx_buf[15] = (uint8_t)(m_str_card_param_info.hole_info[0].TtMin);
- g_uart0_tx_buf[16] = (uint8_t)((m_str_card_param_info.hole_info[0].TtMin-(uint8_t)(m_str_card_param_info.hole_info[0].TtMin))*100);
- /*孔2检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[17] = (uint8_t)(m_str_card_param_info.hole_info[1].item);
- g_uart0_tx_buf[18] = (uint8_t)(m_str_card_param_info.hole_info[1].TtMax);
- g_uart0_tx_buf[19] = (uint8_t)((m_str_card_param_info.hole_info[1].TtMax-(uint8_t)(m_str_card_param_info.hole_info[1].TtMax))*100);
- g_uart0_tx_buf[20] = (uint8_t)(m_str_card_param_info.hole_info[1].TtMin);
- g_uart0_tx_buf[21] = (uint8_t)((m_str_card_param_info.hole_info[1].TtMin-(uint8_t)(m_str_card_param_info.hole_info[1].TtMin))*100);
- /*孔3检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[22] = (uint8_t)(m_str_card_param_info.hole_info[2].item);
- g_uart0_tx_buf[23] = (uint8_t)(m_str_card_param_info.hole_info[2].TtMax);
- g_uart0_tx_buf[24] = (uint8_t)((m_str_card_param_info.hole_info[2].TtMax-(uint8_t)(m_str_card_param_info.hole_info[2].TtMax))*100);
- g_uart0_tx_buf[25] = (uint8_t)(m_str_card_param_info.hole_info[2].TtMin);
- g_uart0_tx_buf[26] = (uint8_t)((m_str_card_param_info.hole_info[2].TtMin-(uint8_t)(m_str_card_param_info.hole_info[2].TtMin))*100);
- /*孔4检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[27] = (uint8_t)(m_str_card_param_info.hole_info[3].item);
- g_uart0_tx_buf[28] = (uint8_t)(m_str_card_param_info.hole_info[3].TtMax);
- g_uart0_tx_buf[29] = (uint8_t)((m_str_card_param_info.hole_info[3].TtMax-(uint8_t)(m_str_card_param_info.hole_info[3].TtMax))*100);
- g_uart0_tx_buf[30] = (uint8_t)(m_str_card_param_info.hole_info[3].TtMin);
- g_uart0_tx_buf[31] = (uint8_t)((m_str_card_param_info.hole_info[3].TtMin-(uint8_t)(m_str_card_param_info.hole_info[3].TtMin))*100);
- /*孔5检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[32] = (uint8_t)(m_str_card_param_info.hole_info[4].item);
- g_uart0_tx_buf[33] = (uint8_t)(m_str_card_param_info.hole_info[4].TtMax);
- g_uart0_tx_buf[34] = (uint8_t)((m_str_card_param_info.hole_info[4].TtMax-(uint8_t)(m_str_card_param_info.hole_info[4].TtMax))*100);
- g_uart0_tx_buf[35] = (uint8_t)(m_str_card_param_info.hole_info[4].TtMin);
- g_uart0_tx_buf[36] = (uint8_t)((m_str_card_param_info.hole_info[4].TtMin-(uint8_t)(m_str_card_param_info.hole_info[4].TtMin))*100);
- /*孔6检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[37] = (uint8_t)(m_str_card_param_info.hole_info[5].item);
- g_uart0_tx_buf[38] = (uint8_t)(m_str_card_param_info.hole_info[5].TtMax);
- g_uart0_tx_buf[39] = (uint8_t)((m_str_card_param_info.hole_info[5].TtMax-(uint8_t)(m_str_card_param_info.hole_info[5].TtMax))*100);
- g_uart0_tx_buf[40] = (uint8_t)(m_str_card_param_info.hole_info[5].TtMin);
- g_uart0_tx_buf[41] = (uint8_t)((m_str_card_param_info.hole_info[5].TtMin-(uint8_t)(m_str_card_param_info.hole_info[5].TtMin))*100);
- /*孔7检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[42] = (uint8_t)(m_str_card_param_info.hole_info[6].item);
- g_uart0_tx_buf[43] = (uint8_t)(m_str_card_param_info.hole_info[6].TtMax);
- g_uart0_tx_buf[44] = (uint8_t)((m_str_card_param_info.hole_info[6].TtMax-(uint8_t)(m_str_card_param_info.hole_info[6].TtMax))*100);
- g_uart0_tx_buf[45] = (uint8_t)(m_str_card_param_info.hole_info[6].TtMin);
- g_uart0_tx_buf[46] = (uint8_t)((m_str_card_param_info.hole_info[6].TtMin-(uint8_t)(m_str_card_param_info.hole_info[6].TtMin))*100);
- /*孔8检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[47] = (uint8_t)(m_str_card_param_info.hole_info[7].item);
- g_uart0_tx_buf[48] = (uint8_t)(m_str_card_param_info.hole_info[7].TtMax);
- g_uart0_tx_buf[49] = (uint8_t)((m_str_card_param_info.hole_info[7].TtMax-(uint8_t)(m_str_card_param_info.hole_info[7].TtMax))*100);
- g_uart0_tx_buf[50] = (uint8_t)(m_str_card_param_info.hole_info[7].TtMin);
- g_uart0_tx_buf[51] = (uint8_t)((m_str_card_param_info.hole_info[7].TtMin-(uint8_t)(m_str_card_param_info.hole_info[7].TtMin))*100);
- /*孔9检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[52] = (uint8_t)(m_str_card_param_info.hole_info[8].item);
- g_uart0_tx_buf[53] = (uint8_t)(m_str_card_param_info.hole_info[8].TtMax);
- g_uart0_tx_buf[54] = (uint8_t)((m_str_card_param_info.hole_info[8].TtMax-(uint8_t)(m_str_card_param_info.hole_info[8].TtMax))*100);
- g_uart0_tx_buf[55] = (uint8_t)(m_str_card_param_info.hole_info[8].TtMin);
- g_uart0_tx_buf[56] = (uint8_t)((m_str_card_param_info.hole_info[8].TtMin-(uint8_t)(m_str_card_param_info.hole_info[8].TtMin))*100);
- /*孔10检测项目ID、TtMax(整数+小数)、TtMin(整数+小数)*/
- g_uart0_tx_buf[57] = (uint8_t)(m_str_card_param_info.hole_info[9].item);
- g_uart0_tx_buf[58] = (uint8_t)(m_str_card_param_info.hole_info[9].TtMax);
- g_uart0_tx_buf[59] = (uint8_t)((m_str_card_param_info.hole_info[9].TtMax-(uint8_t)(m_str_card_param_info.hole_info[9].TtMax))*100);
- g_uart0_tx_buf[60] = (uint8_t)(m_str_card_param_info.hole_info[9].TtMin);
- g_uart0_tx_buf[61] = (uint8_t)((m_str_card_param_info.hole_info[9].TtMin-(uint8_t)(m_str_card_param_info.hole_info[9].TtMin))*100);
- #endif
- memcpy(g_uart0_tx_buf + 4, (uint8_t*)p_str_card_param_info, sizeof(str_card_param_info_t));
- g_uart0_tx_buf[62] = 0x55; // 帧尾
- g_uart0_tx_buf[63] = 0xBB; // 帧尾
- UART_Write(UART0, g_uart0_tx_buf, 64);
- }
|