Set Receive Non Iso Tp CAN Frames

A free API for the transfer of data packages according to ISO-TP (ISO 15765-2)
Locked
C.L.W.
Posts: 3
Joined: Fri 12. Jan 2018, 10:50

Set Receive Non Iso Tp CAN Frames

Post by C.L.W. » Fri 12. Jan 2018, 10:56

Hallo,
ich habe Probleme beim Setzen des Parameters: PCANTP_PARAM_CAN_UNSEGMENTED

Mit welchem Typ muss man die Getvalue Funktion aufrufen ?
Ich habe es mit Uinteger, Byte, Byte() versucht.
Als Status erhalte ich jedes Mal: -2080374784 was darauf hin deutet, dass auf einen falschen Speicherbereich zugegriffen wird bzw. etwas mit dem Marshalling nicht geklappt hat.

F.Vergnaud
Software Development
Software Development
Posts: 170
Joined: Mon 9. Sep 2013, 12:21

Re: Set Receive Non Iso Tp CAN Frames

Post by F.Vergnaud » Fri 12. Jan 2018, 12:28

Hello C.L.W.,

Parameter PCANTP_PARAM_CAN_UNSEGMENTED requires a numeric buffer, the minimum expected size is 1. Here are examples for both C++ and C#.

C++ example:

Code: Select all

	
	TPCANTPStatus sts;
	BYTE param = PCANTP_CAN_UNSEGMENTED_ALL_FRAMES;	// value: 1=ON, 2=ALL
	sts = CANTP_SetValue(ChannelRcv, PCANTP_PARAM_CAN_UNSEGMENTED, &param, 1);
...
C# example:

Code: Select all

	TPCANTPStatus sts;
	uint iBuf = CanTpApi.PCANTP_CAN_UNSEGMENTED_ON;
	TPCANTPParameter param = TPCANTPParameter.PCANTP_PARAM_CAN_UNSEGMENTED;
	sts = CanTpApi.SetValue(m_pctpHandle, param, ref iBuf, sizeof(uint));
...
Best regards,
Fabrice

C.L.W.
Posts: 3
Joined: Fri 12. Jan 2018, 10:50

Re: Set Receive Non Iso Tp CAN Frames

Post by C.L.W. » Fri 12. Jan 2018, 12:57

Thanks for your quick reply

Valid values of the Parameter should be:

Code: Select all

 
Public Enum FrameReception As Integer
        <Description("Disable reception of unformatted (NON-ISO-TP) CAN frames (default): only ISO 15765 messages will be received")>
        Unsegmented_Off = &H0
        <Description("Enable reception of unformatted (NON-ISO-TP) CAN frames: received messages will be treated as either ISO 15765 Or as an unformatted CAN frame")>
        Unsegmented_On = &H1
        <Description("Enable reception of unformatted (NON-ISO-TP) CAN frames: received messages will be treated as ISO 15765, unformatted CAN frame, Or both (user will able to read fragmented CAN frames")>
        Unsegmented_AllFrames = &H2
    End Enum
But it is only possible to set Unsegmented_Off. It isn't possible to use Unsegmented_On or Unsegmented_AllFrames

Code: Select all

Public Sub GetFrameReception(ByRef fr As FrameReception)
        Try
            Dim buffer As UInteger
            Status = IsoTpApi.GetValue(Handle, PCANTP_PARAM_CAN_UNSEGMENTED, buffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(buffer), UInteger))
            frameReception = CType(buffer, FrameReception)
        Catch ex As Exception
            SetLog(StatusDescription, ex, LogLevel.DEBUG, True)
        End Try
    End Sub
result of IsoTpApi.GetValue is still -2080374784

F.Vergnaud
Software Development
Software Development
Posts: 170
Joined: Mon 9. Sep 2013, 12:21

Re: Set Receive Non Iso Tp CAN Frames

Post by F.Vergnaud » Fri 12. Jan 2018, 16:07

Thank you for your input. The problem is a typo in the VB.Net header where PCANTP_PARAM_CAN_UNSEGMENTED is defined. The parameter value should be &HE9 instead of &H9.

PCAN-ISO-TP.vb, line 273 was:

Code: Select all

        ''' <summary>
        '''  1 BYTE data stating if unsegmented (NON-ISO-TP) CAN frames can be received
        ''' </summary>
        PCANTP_PARAM_CAN_UNSEGMENTED = &H9
You can fix the issue by changing the value in your VB header to:

Code: Select all

        ''' <summary>
        '''  1 BYTE data stating if unsegmented (NON-ISO-TP) CAN frames can be received
        ''' </summary>
        PCANTP_PARAM_CAN_UNSEGMENTED = &HE9
Sorry for the inconvenience.
Best regards,
Fabrice

Locked