5,955
社区成员
发帖
与我相关
我的任务
分享
def SendMoreMsg(self,DataId,TxData)->None:#多帧发送:10111213141516171819 msg: str = TxData.replace("","") msg1: str = msg.replace(",","") Txlen:str = "%03X" % (int(len(msg1)/2 + 4096))#计算出需要发送数据的有效长度 SendMsgNum = ((len(msg1)/2) -6)/7 FF_Msg = Txlen + msg1[4:16] MsgForFirstData = "20,21,22,23,24,25,26,27,28,29,2A,2B,2C,2D,2E,2F" #WithoutFFData = TxData[16:] # for i in #WithoutFFData = WithoutFFData[] MSG = CAN_MSG() MSG.ID = DataId MSG.DataLen = 8 MSG.RemoteFlag = 0 MSG.ExternFlag = 0 for i in range(0,8): MSG.Data[i] = int(FF_Msg[i*2:i*2+2],16) ret = CAN_SendMsg(self.DevHandle,0,byref(MSG),1)#首诊发送 TMScandevice1.ResCanData(0,0x79C) if len(msg1) <= 236: WithoutFFData = TxData[12:]#16171819 # print(WithoutFFData) for i in range(1,6): MsgForFirstData = MsgForFirstData.replace(",","") MsgForFirstData = MsgForFirstData.replace(" ","") # print(MsgForFirstData) MSG.Data[0] = int(MsgForFirstData[i*2:i*2+2],16)#连续帧帧头 for i in range(1,8): MSG.Data[i] = WithoutFFData[i] print(MSG.Data[0:8]) ret = CAN_SendMsg(self.DevHandle,0,byref(MSG),1)#该如何去规定我最终 time.sleep(0.01) print(ret)
多帧发送的代码如上,目前问题卡在了发送首帧之后,连续帧的发送无法通过程序自动实现,想问问社区的大佬们如何进行处理?