CanTpApi.Initialize takes very long (+30s)
Posted: Thu 30. Mar 2017, 09:09
Any idea why the first time for every channel the cantpapi.init takes ages (+30s).... we have 4 can cards in our pc... so it will take up to 4x30s ....
Code is very simple ... see below ...
public int SetupCommunication(int channel)
{
//----------------------------
// setup uds connection
//----------------------------
byte canchannel = (byte)(0x40 | channel);
//init UDS connection
TPCANTPStatus sts;
// Connects to the selected PCAN-ISO-TP channel.
sts = CanTpApi.Initialize(canchannel, TPCANTPBaudrate.PCANTP_BAUD_33K);
Trace.WriteLine(string.Format("CANTP INIT : {0}",sts));
//do mappings
sts = CanTpApi.Reset(canchannel);
Trace.WriteLine(string.Format("CANTP RESET : {0}", sts));
sts = CanTpApi.RemoveMapping(canchannel, 0x24c);
sts = CanTpApi.RemoveMapping(canchannel, 0x64c);
sts = CanTpApi.AddMapping(canchannel, 0x24c, 0x64c,
TPCANTPIdType.PCANTP_ID_CAN_11BIT, TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
0x1a,
0x1b,
TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, 0x00);
Trace.WriteLine(string.Format("CANTP MAP1 : {0}", sts));
sts = CanTpApi.AddMapping(canchannel, 0x64c, 0x24c,
TPCANTPIdType.PCANTP_ID_CAN_11BIT, TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
0x1b,
0x1a,
TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, 0x00);
Trace.WriteLine(string.Format("CANTP MAP2 : {0}", sts));
return 0;
}
Code is very simple ... see below ...
public int SetupCommunication(int channel)
{
//----------------------------
// setup uds connection
//----------------------------
byte canchannel = (byte)(0x40 | channel);
//init UDS connection
TPCANTPStatus sts;
// Connects to the selected PCAN-ISO-TP channel.
sts = CanTpApi.Initialize(canchannel, TPCANTPBaudrate.PCANTP_BAUD_33K);
Trace.WriteLine(string.Format("CANTP INIT : {0}",sts));
//do mappings
sts = CanTpApi.Reset(canchannel);
Trace.WriteLine(string.Format("CANTP RESET : {0}", sts));
sts = CanTpApi.RemoveMapping(canchannel, 0x24c);
sts = CanTpApi.RemoveMapping(canchannel, 0x64c);
sts = CanTpApi.AddMapping(canchannel, 0x24c, 0x64c,
TPCANTPIdType.PCANTP_ID_CAN_11BIT, TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
0x1a,
0x1b,
TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, 0x00);
Trace.WriteLine(string.Format("CANTP MAP1 : {0}", sts));
sts = CanTpApi.AddMapping(canchannel, 0x64c, 0x24c,
TPCANTPIdType.PCANTP_ID_CAN_11BIT, TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,
0x1b,
0x1a,
TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL, 0x00);
Trace.WriteLine(string.Format("CANTP MAP2 : {0}", sts));
return 0;
}