From 522d71bec0ef85c6f900f0129ec927fe60e279c5 Mon Sep 17 00:00:00 2001 From: JiaXingyu Date: Sun, 28 Sep 2025 16:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20'BHBF=5Fdecoder.lua'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BHBF_decoder.lua | 159 ----------------------------------------------- 1 file changed, 159 deletions(-) delete mode 100644 BHBF_decoder.lua diff --git a/BHBF_decoder.lua b/BHBF_decoder.lua deleted file mode 100644 index fda9b53..0000000 --- a/BHBF_decoder.lua +++ /dev/null @@ -1,159 +0,0 @@ ---分窗标志定义 -WIN_0 = 0x0001 -WIN_1 = 0x0002 -WIN_2 = 0x0004 -WIN_3 = 0x0008 -WIN_4 = 0x0010 -WIN_5 = 0x0020 -WIN_6 = 0x0040 -WIN_7 = 0x0080 -WIN_8 = 0x0100 -WIN_9 = 0x0200 -WIN_10 = 0x0400 -WIN_11 = 0x0800 -WIN_12 = 0x1000 -WIN_13 = 0x2000 -WIN_14 = 0x4000 -WIN_15 = 0x8000 - - ---GV索引字符串 -local GVstr = { - "State_Index_U", - "State_Index_U_Elapse", - "State_Index_N", - "State_Index_N_Elapse", - "NC_ARRAY_u8_0", - "NC_ARRAY_u8_01", - "NC_ARRAY_u8_1", - "NC_ARRAY_u8_11", - "NC_ARRAY_u8_2", - "MK32_Key.RxIndex", - "MK32_Key.CH0_RY_H", - "MK32_Key.CH1_RY_V", - "MK32_Key.CH2_LY_V", - "MK32_Key.CH3_LY_H", - "MK32_Key.CH4_SA", - "MK32_Key.CH5_SB", - "MK32_Key.CH6_SC", - "MK32_Key.CH7_SD", - "MK32_Key.CH8_SE", - "MK32_Key.CH9_SF", - "MK32_Key.CH10_LD1", - "MK32_Key.CH11_RD1", - "MK32_Key.CH12_S1", - "MK32_Key.CH13_S2", - "MK32_Key.CH14_LT", - "MK32_Key.CH15_RT", - "MK32_Key.IsOnline", - "Motor_P[0]MotorID", - "Motor_P[0]RxIndex", - "Motor_P[0]Run_Mode", - "Motor_P[0]Current", - "Motor_P[0]Target_Current", - "Motor_P[0]Velcity", - "Motor_P[0]Target_Velcity", - "Motor_P[0]Position", - "Motor_P[0]Target_Position", - "Motor_P[0]ERROR_Flag", - "Motor_P[0]Temperature_Motor", - "Motor_P[0]Temperature_PCB", - "Motor_P[1]MotorID", - "Motor_P[1]RxIndex", - "Motor_P[1]Run_Mode", - "Motor_P[1]Current", - "Motor_P[1]Target_Current", - "Motor_P[1]Velcity", - "Motor_P[1]Target_Velcity", - "Motor_P[1]Position", - "Motor_P[1]Target_Position", - "Motor_P[1]ERROR_Flag", - "Motor_P[1]Temperature_Motor", - "Motor_P[1]Temperature_PCB", - "Motor_P[2]MotorID", - "Motor_P[2]RxIndex", - "Motor_P[2]Run_Mode", - "Motor_P[2]Current", - "Motor_P[2]Target_Current", - "Motor_P[2]Velcity", - "Motor_P[2]Target_Velcity", - "Motor_P[2]Position", - "Motor_P[2]Target_Position", - "Motor_P[2]ERROR_Flag", - "Motor_P[2]Temperature_Motor", - "Motor_P[2]Temperature_PCB" -} - ---CAN 解码函数,返回的字符串将展示到数据窗口 ---id 帧ID ---std_ext 0表示标准帧, 1表示扩展帧 ---data_remote 0表示数据帧, 1表示远程帧 ---datalen 数据长度,字节 ---data_bin 二进制数据 ---函数返回: ret1解码字符串 , ret2分窗控制字, 波形数据字符串 -function can_decoder(id, std_ext, data_remote, datalen, data_bin) - local ret1 = "" --返回值1 解码显示结果 - local ret2 = 0 --返回值2 分窗标志 - local bin = {} - local i - local str_wave = "" - - local _index = 0 - local _value = 0 - --local a_string = string.pack(">i2", your_integer) - --local an_integer = string.unpack(">i2", a_string, start) 将二进制字符串转换为数字类型,从第start个字符开始,<小端 >大端,类型i2,长度2 - - --#将字符串转换到整数数组存放 - for i = 1,#data_bin,1 do - bin[i] = tonumber(string.byte(data_bin, i,i)) - end - - --计算解码结果,将显示在数据包后面 - if (id == 0x120) then - _index = string.unpack("