/* EOL CAPL test: commission and verify all LIN slaves */
variables {
linFrame MasterReq;
linFrame SlaveResp;
int pass_count = 0;
int total_slaves = 3;
}
/* Assign Window_FL slave: 0x7F → 0x01 */
void AssignNAD(byte initial_nad, byte supplier_lo, byte supplier_hi,
byte func_lo, byte func_hi, byte new_nad)
{
MasterReq.nad = initial_nad;
MasterReq.byte(0) = 0x06; /* PCI: SF, length=6 */
MasterReq.byte(1) = 0xB0; /* SID: AssignNAD */
MasterReq.byte(2) = supplier_lo;
MasterReq.byte(3) = supplier_hi;
MasterReq.byte(4) = func_lo;
MasterReq.byte(5) = func_hi;
MasterReq.byte(6) = new_nad;
MasterReq.byte(7) = 0xFF;
linMasterSendDiag(MasterReq);
}
on linFrame SlaveResp {
/* Check ReadByIdentifier response: Supplier+Function must match LDF */
if (this.byte(1) == 0xF2 && /* Positive response to ReadByIdentifier */
this.byte(2) == 0x05 && this.byte(3) == 0x00) { /* Supplier=0x0005 */
pass_count++;
write("PASS: Slave at NAD=0x%02X verified (%d/%d)", this.nad, pass_count, total_slaves);
} else {
write("FAIL: Unexpected response from NAD=0x%02X", this.nad);
}
}