CMD0x02_Request_ReadMcuVersion.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "string.h"
  2. #include "CommandsDefine.h"
  3. #include "usart.h"
  4. #include "ProjectConfig.h"
  5. /* 获取当前程序是的版本等信息*/
  6. /*
  7. 请求格式 包起始标识+CMD0x02_Request_ReadMcuVersion+[0x00+0x00]+包尾标识
  8. 返回格式:
  9. 包起始标识
  10. +CMD0x03_Request_ReadMcuBootVersion
  11. +[2字节的数据长度,=129]
  12. +1字节的主版本号+1字节的次版本号+1字节的修订版本
  13. +Version_DateLength=14字节的日期时间标识,是YYYYMMDDHHMMSS格式的ascii码
  14. +Version_ModifierNameMaxLength=16字节的最后修改人姓名。其余的填0
  15. +Version_ModelNameMaxLength=32字节的型号标识
  16. +Version_Comment_MaxLength=64字节的备注信息
  17. +包尾标识
  18. */
  19. void CMD0x02_Request_ReadMcuVersion_process(u8 *pData,u16 dataLen,u8 bIsContentBitInverted_Recv,u8 bIsContentBitInverted_SendBack)
  20. {
  21. u8 backdataLength=3
  22. +Version_DateLength
  23. +Version_ModifierNameMaxLength
  24. +Version_ModelNameMaxLength
  25. +Version_Comment_MaxLength;
  26. memset(USART_WR_BUF,0,backdataLength);
  27. int len;
  28. VersionInfo* versionInfo=GetVersion();
  29. USART_WR_BUF[0]=versionInfo->Version_MainNo;
  30. USART_WR_BUF[1]=versionInfo->Version_SubNo;
  31. USART_WR_BUF[2]=versionInfo->Version_ModifyNo;
  32. for(int i=0;i<Version_DateLength;i++)
  33. USART_WR_BUF[3+i]=versionInfo->Version_Date[i];
  34. len=strlen(versionInfo->Version_ModifierName);
  35. len=len>Version_ModifierNameMaxLength ? Version_ModifierNameMaxLength:len;
  36. for(int i=0;i<len;i++)
  37. USART_WR_BUF[3+Version_DateLength+i]=versionInfo->Version_ModifierName[i];
  38. len=strlen(versionInfo->Version_ModelName);
  39. len=len>Version_ModelNameMaxLength ? Version_ModelNameMaxLength:len;
  40. for(int i=0;i<len;i++)
  41. USART_WR_BUF[3+Version_DateLength+Version_ModifierNameMaxLength+i]=versionInfo->Version_ModelName[i];
  42. len=strlen(versionInfo->Version_Comment);
  43. len=len>Version_Comment_MaxLength ? Version_Comment_MaxLength:len;
  44. for(int i=0;i<len;i++)
  45. USART_WR_BUF[3+Version_DateLength+Version_ModifierNameMaxLength+Version_ModelNameMaxLength+i]=versionInfo->Version_Comment[i];
  46. int sendSize=Command_FormatCmdBuffer(CMD0x03_Request_ReadMcuBootVersion,USART_WR_BUF,backdataLength,USART_WR_BUF_LAST);
  47. USART6_Send(CMD0x02_Request_ReadMcuVersion,backdataLength,bIsContentBitInverted_SendBack);
  48. }