Tools/DataStruct.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AgingTest.Tools;

namespace AgingTest.Tools
{
    public class SendCheckData
    {
        
        public byte[] SendData = new byte[15];  //存放最终要发送的数据

        public byte[] DataType = new byte[1];   //包类型
        public byte[] DataLength = new byte[2]; //数据长度
        public byte[] CANID = new byte[2];      //CANId
        public byte[] CommCode = new byte[1];   //指令代码
        public byte[] MotoId = new byte[4];     //电机ID
        public byte[] CRCCode = new byte[4];      //4位CRC校验
        public byte[] EndCode = new byte[1];    //结束码

        /// <summary>
        /// 组装 开始测试 数据结构
        /// </summary>
        /// <param name="str_CANID"></param>
        public void AssembleData_Begin(string str_CANID)
        {
            CommCode = new byte[] { 0x02 };     //指令代码为 开始测试

            DataType = new byte[] { 0x0A };
            DataLength = new byte[] { 0x0F, 0x00 };
            CANID = CANToHex(str_CANID); 
            MotoId = new byte[] { 0x01, 0x00, 0x00, 0x00 };
            EndCode[0] = 0xFF;

            byte[] temp = new byte[10];
            Array.Copy(DataType, 0, temp, 0, 1);
            Array.Copy(DataLength, 0, temp, 1, 2);
            Array.Copy(CANID, 0, temp, 3, 2);
            Array.Copy(CommCode, 0, temp, 5, 1);
            Array.Copy(MotoId, 0, temp, 6, 4);
            CRCCode = CRC32.Calculate_CRC32_Byte(temp);

            Array.Copy(DataType, 0, SendData, 0, 1);
            Array.Copy(DataLength, 0, SendData, 1, 2);
            Array.Copy(CANID, 0, SendData, 3, 2);
            Array.Copy(CommCode, 0, SendData, 5, 1);
            Array.Copy(MotoId, 0, SendData, 6, 4);
            Array.Copy(CRCCode, 0, SendData, 10, 4);
            Array.Copy(EndCode, 0, SendData, 14, 1);

            

        }

        //组装轮询
        public void AssembleData_Polling(string str_CANID)
        {
            CommCode = new byte[] { 0x00 };     //指令代码为 轮询
后面还有 82 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。