[CanTp] Vehicle Diagnostic Communication Part 36 [Simulation 24]

[CanTp] Vehicle Diagnostic Communication Part 36 [Simulation 24] 車両診断通信
[CanTp] Vehicle Diagnostic Communication Part 36 [Simulation 24]

Click here for back issues.
https://www.simulationroom999.com/blog/diagnostic-communication-en-back-issue/

Introduction.

Let’s simulate ISO-TP. series.
In this article, I will explain the structure definition of the configuration of CanTp.

Configuration structure for AUTOSAR-CanTp

It would be faster to quickly look at the source code for the structure definitions.
It is as follows.

CH_RX_CB ch_rx_cb[2] = {0};
CH_TX_CB ch_tx_cb[2] = {0};

CH_INIB ch_inib_table[1] = {
	{
		CANTP_MODE_HALF_DUPLEX,	/* Channel communication method */
		&ch_rx_cb[0],				/* Channel Reception Control Block */
		&ch_tx_cb[0],				/* Channel Transmission Control Block */
	},
};

TX_NSDU_INIB tx_nsdu_inib = {
	0,	/* PduId of CanIf specified when sending SF, FF, or CF with CanIf_Transmit */
	0,	/* PduId of CanTp specified when SF, FF, CF transmission is completed in CanTp_TxConfirmation */
	1,	/* PduId of CanTp specified when FC is received in CanTp_RxIndication */
	0,	/* PduId specified for PduR_CanTpTxConfirmation */
};

RX_NSDU_CB rx_nsdu_cb = {
	0,	/*STmin*/
	0,	/*BS*/
};

RX_NSDU_INIB rx_nsdu_inib = {
	5,	/* Maximum number of FC (WAIT) transmissions */
	0,	/* STmin value */
	0,	/* BS Value */
	2,	/* PduId of CanIf to be specified when sending FC with CanIf_Transmit */
	2,	/* PduId of CanTp specified when SF, FF, or CF is received in CanTp_RxIndication */
	3,	/* PduId of CanTp specified when FC transmission is completed in CanTp_TxConfirmation */
	2,	/* PduId specified during PduR_CanTpRxIndication */
	&rx_nsdu_cb,	/* Received NSDU Control Block */	
};

const NSDU_INIB nsdu_inib_table[4] = {
	{
		0,				/* Channel number belonging to */
		CANTP_SEND,		/* NSDU transmission and reception direction */
		1000,			/* N_Ar/N_As timeout value */
		1000,			/* N_Br/N_Bs timeout value */
		1000,			/* N_Cr/N_Cs timeout value */
		CANTP_ON,		/* Permission/prohibition of communication abort */
		CANTP_NORMALFIXED,	/* address format */
		CANTP_ON,		/* Whether Padding is used or not */
		CANTP_PHYSICAL,	/* N-SDU communication type */
		0,				/* N_AE */
		0x10,			/* N_SA */
		0xF1,			/* N_TA */
		7,				/* Maximum SDU data length (single frame) */
		4095,			/* Maximum SDU data length (multi-frame) */
		7,				/* SF Maximum Data Length */
		6,				/* FF Maximum Data Length */
		7,				/* CF Maximum Data Length */
		&tx_nsdu_inib,		/* NSDU initialization block by transmission and reception */
	},
	{
		0,				/* Channel number belonging to */
		CANTP_RECEIVE,		/* NSDU transmission and reception direction */
		1000,			/* N_Ar/N_As timeout value */
		1000,			/* N_Br/N_Bs timeout value */
		1000,			/* N_Cr/N_Cs timeout value */
		CANTP_ON,		/* Permission/prohibition of communication abort */
		CANTP_NORMALFIXED,	/* address format */
		CANTP_ON,		/* Whether Padding is used or not */
		CANTP_PHYSICAL,	/* N-SDU communication type */
		0,				/* N_AE */
		0xF1,			/* N_SA */
		0x10,			/* N_TA */
		7,				/* Maximum SDU data length (single frame) */
		4095,			/* Maximum SDU data length (multi-frame) */
		7,				/* SF Maximum Data Length */
		6,				/* FF Maximum Data Length */
		7,				/* CF Maximum Data Length */
		&rx_nsdu_inib,		/* NSDU initialization block by transmission and reception */
	},
};

PduIdType	pduid_to_nsduid_table[2] = {0,1};

CanTp_ConfigType cantp_config[1] = {
	1,				/* Number of channels */
	ch_inib_table,	/* channel initialization block array */
	2,				/* Number of NSDUs */
	nsdu_inib_table,	/* NSDU initialization block array */
	2,				/* Number of PDUs */
	pduid_to_nsduid_table,	/* PduID allocation table */
	1,				/* cycle */
};

Most of you probably don’t understand what I mean….
I did my best to comment on this….

About PduId in CanIf

First of all, you probably don’t understand the PduId in some places.

Simply put, CanIf has a CANID tied to PudId internally.
In this case, PudId has the following meaning.
0: Transmission of 0x18DAF110
1: Receiving 0x18DA10F1
2: Transmission of 0x18DA10F1
3: Receipt of 0x18DAF110

CH_RX_CB (Receive Control Block) and CH_TX_CB (Transmit Control Block)

You may also be interested in the following definitions at the top.

CH_RX_CB ch_rx_cb[2] = {0};
CH_TX_CB ch_tx_cb[2] = {0};

It does not appear to define anything in particular, just initialized with a zero value.
The area here is used for the actual communication work.
As a structure, it is defined as follows.

typedef struct rx_control_block {
	PduIdType		id;				/* ID currently being received */
	uint8			rx_status;		/* Receiving Status */
	uint8			rx_time;		/* Receive timeout count status (Stop/N_Ar/N_Br/N_Cr) */
	uint32			rx_time_cnt;	/* time-out counter */
	PduLengthType	sdu_len;		/* SDU data length */
	PduLengthType	data_len;		/* Remaining received data length */
	uint8			cf_sn;			/* Sequence number to be received next in CF */
	uint8			fc_fs;			/* FS transmitted by FC */
	uint8			fc_bs;			/* BS transmitted by FC */
	uint8			fc_stmin;		/* STmin transmitted by FC */
	uint8			bs_cnt;			/* Received CF Counter */
	uint8			wft_cnt;		/* Transmit FC (WAIT) counter */
} CH_RX_CB;

These are used for communication and must be filled with zeros when initializing.

These are what make multi-channel possible.
If there is no memory constraint, it is possible to define as many channels as possible.
In reality, however, the maximum number of channels is 65535, because the type that defines the number of channels is 16 bits long.
Realistically, it would be a good number to say any number.

Now that we have the definitions, let’s try the actual operation next time!

Conclusion

  • We defined a concrete configuration structure for AUTOSAR-CanTp.
  • The number PduId is used when interacting with CanIf.
    • In this case, the following.
      • 0: Transmission of 0x18DAF110.
      • 1: Receipt of 0x18DA10F1.
      • 2: Transmission of 0x18DA10F1.
      • 3: Receipt of 0x18DAF110.
  • The Receive Control Block for CH_RX_CB and the Transmit Control Block for CH_TX_CB are for work.

Click here for back issues.

コメント

タイトルとURLをコピーしました