ISO TP c# application
Posted: Wed 18. May 2016, 11:06
Hello,
we are developing an app to send and receive messages using TP layer in our end-of-line ECU testing system.
this is our code:
the message that we send is:
CAN-ID, lenght, Data
400, 8, 1F FF 8B 06 01 30 00 00
we would obtain:
400, 8, 8B 06 01 30 00 00 00 00
Is it possible to achieve this result changing some param ?
Thanks,
N.
we are developing an app to send and receive messages using TP layer in our end-of-line ECU testing system.
this is our code:
Code: Select all
//MAPPING
public void ConfigureCAN_ISOTP()
{
TPCANTPStatus result;
// The Plug & Play Channel (PCAN-USB) is initialized
result = CanTpApi.Initialize(CanTpApi.PCANTP_USBBUS1, TPCANTPBaudrate.PCANTP_BAUD_500K);
if (result != TPCANTPStatus.PCANTP_ERROR_OK)
MessageBox.Show("Initialization failed");
else
{
TPCANTPStatus s;
// Define ISO-TP communication from Client to ECU (physical requests)
s = CanTpApi.AddMapping(CanTpApi.PCANTP_USBBUS1, 0x400, 0x401,
TPCANTPIdType.PCANTP_ID_CAN_11BIT,
TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
0x8b, 0xf1,
TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
0X00);
MessageBox.Show("PCAN-USB (Ch-1) was initialized");
}
// All initialized channels are released
}
// MAIN CODE
ConfigureCAN_ISOTP();
TPCANTPStatus result;
TPCANTPMsg request = new TPCANTPMsg();
TPUDSMsg requestConfirmation = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
request.DATA = new byte[4095];
string CMD_ID = "0130";
int CMD_PARAM = 00;
byte[] cmdId = HexStringConverter.GetBytes(CMD_ID);
UInt32 CMD_ID0 = Convert.ToUInt32(cmdId[0]);
UInt32 CMD_ID1 = Convert.ToUInt32(cmdId[1]);
request.DATA[0]= HexStringConverter.GetBytes("8B")[0];
request.DATA[1] = HexStringConverter.GetBytes("06")[0];
request.DATA[2] = Convert.ToByte(CMD_ID0.ToString());
request.DATA[3] = Convert.ToByte(CMD_ID1.ToString());
request.DATA[4] = Convert.ToByte(CMD_PARAM);
request.DATA[5] = Convert.ToByte((0 & 0x01 | 0 << 2 & 0x02 | 0 << 2 & 0x03));
request.DATA[6] = 0;
request.DATA[7] = 0;
//request.DATA[8] = 0;
request.LEN = (ushort)request.DATA.Length;
request.MSGTYPE = TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC;
request.SA = (byte)0X8b;
request.TA = (byte)0Xf1;
request.TA_TYPE = TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL;
request.RA = 0x00;
request.FORMAT = TPCANTPFormatType.PCANTP_FORMAT_NORMAL;
request.IDTYPE = TPCANTPIdType.PCANTP_ID_CAN_11BIT;
result = CanTpApi.Write(CanTpApi.PCANTP_USBBUS1, ref request);
CAN-ID, lenght, Data
400, 8, 1F FF 8B 06 01 30 00 00
we would obtain:
400, 8, 8B 06 01 30 00 00 00 00
Is it possible to achieve this result changing some param ?
Thanks,
N.