/// <summary> /// /// </summary> /// <param name="reqID"></param> /// <param name="resID"></param> /// <param name="data"></param> /// <param name="timeOut"></param> /// <param name="externFlag"></param> /// <returns>Length of recieved data</returns> public int UDSRes(uint reqID, uint resID, byte[] data, int timeOut, bool externFlag = false, int sleepAfterSend = 55) { Logger.LogLine($"Listening data from 0x{reqID:X2}"); int v = CAN_UDS.CAN_UDS_Response(DeviceHandle, canIndex, new CAN_UDS.CAN_UDS_ADDR { ExternFlag = (byte)(externFlag ? 0x01 : 0x00), AddrFormats = 0, ReqID = reqID, ResID = resID }, data, timeOut); if (sleepAfterSend > 0) { Thread.Sleep(sleepAfterSend); } return(v); }
/// <summary> /// /// </summary> /// <param name="reqID"></param> /// <param name="resID"></param> /// <param name="data"></param> /// <param name="externFlag"></param> /// <returns> /// <para/>OK 0 /// <para/>TRAN_USB -98 /// <para/>TRAN_CAN -99 /// <para/>TIMEOUT_A -100 /// <para/>TIMEOUT_Bs -101 /// <para/>TIMEOUT_Cr -102 /// <para/>WRONG_SN -103 /// <para/>INVALID_FS -104 /// <para/>UNEXP_PDU -105 /// <para/>WFT_OVRN -106 /// <para/>BUFFER_OVFLW -107 /// <para/>ERROR -108 /// </returns> public int UDSReq(uint reqID, uint resID, byte[] data, bool externFlag = false, int sleepAfterRecieve = 55) { Logger.Log("\r\n"); Logger.Log($"Sending {data[0]:X2} {data[1]:X2}... to 0x{reqID:X2}"); int v = CAN_UDS.CAN_UDS_Request(DeviceHandle, canIndex, new USB2XXX.CAN_UDS.CAN_UDS_ADDR { ExternFlag = (byte)(externFlag ? 0x01 : 0x00), AddrFormats = 0, ReqID = reqID, ResID = resID }, data, data.Length); Logger.Log($"\t{(v == 0 ? "Success" : "Fail")}"); if (sleepAfterRecieve > 0) { Thread.Sleep(sleepAfterRecieve); } return(v); }