TMC32_QJB/App/communication.h
2026-04-30 16:23:12 +08:00

97 lines
2.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
******************************************************************************
* @file communication.c
* @author TMC Scan Team
* @version V1.0.0
* @date 09/06/2019
* @brief
******************************************************************************
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, TMC SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>&copy; COPYRIGHT 2016 TMC</center></h2>
******************************************************************************
**/
#ifndef __COMMUNICATION_H__
#define __COMMUNICATION_H__
#include "global.h"
/** @defgroup HIDPOS communication protocal
* @{
*/
#define HIDPOS_BUFLEN 64 //HIDPOS数据包长度
#define NOTAILLEN (HIDPOS_BUFLEN - 8) //自动上传扫码协议去除8个字节的长度
#define HIDPOS_RECEIVE_DATA_HEAD 0x04
#define HIDPOS_RECEIVE_DATA_TAIL_CONTINUE 0x01
#define HIDPOS_RECEIVE_DATA_TAIL_FINISH 0x00
#define HIDPOS_RECEIBE_DATA_MAX_LEN 60
#define HIDPOS_SEND_DATA_HEAD 0x02
#define HIDPOS_SEND_DATA_MAX_LEN 0x38
/**
* @}
*/
//hidpos 接收数据协议格式
typedef struct
{
uint8_t reportID;
uint8_t dataLen;
uint8_t dataBlock[60];
uint8_t reservedData;
uint8_t endPackage;
} HIDPOSReciveData;
/** @defgroup receive data
* @{
*/
#define MAX_SEND_DATA_LEN 2100
#define MAX_RECEIVE_DATA_LEN 512
#define MAX_RECEIVE_AVAILABLE_DATA_LEN 240
/**
* @}
*/
/** @defgroup receive data flag
* @{
*/
#define RECEIVE_FAIL 0x01
#define RECIEVE_OVERMAXLEN 0x02
#define HIDPOS_RECIEVE_REPORTID_ERROR 0x03
#define HIDPOS_RECIEVE_DATALEN_ERROR 0x04
#define HIDPOS_RECIEVE_PACKAGEEND_ERROR 0x05
#define HIDPOS_RECIEVE_CONTINUE 0x06
#define RECIEVE_FINISH 0x07
/**
* @}
*/
extern uint8_t gOutputBuf[MAX_SEND_DATA_LEN]; //发送数据BUF局限性最大支持2070字节
extern uint8_t gReceiveDataFinish;
extern uint8_t gReceiveBuf[]; //USB接收数据BUF局限性最大支持256字节
extern uint16_t gReceiveLen; //接收数据长度
//函数声明
void ClearOutputLen(void) ;
void SetOutputData(uint8_t *pSrcData, uint16_t uLen);
void ReportData(int barType);
uint8_t VSPRecieveData(void);
void HIDPOSDataSend(uint8_t *pSrc, uint16_t uLen);
uint8_t HIDPOSRecieveData(void);
void CommunicationCmdHandle(BarData *comdata);
uint8_t USBRespondCmd(uint8_t status, BarData *pCode);
uint8_t RecieveData(BarData *pRecievedata);
#endif /*__COMMUNICATION_H__*/