Example 1: A large customer had an intermittent problem on a drivetrain bus. The suspected cause was a faulty multipacket broadcast data transfer (BAM), with packets being received out of sequence. An engineer spent a few days in a truck along with the driver, trying to catch a trace of the problem, before trying out a Kvaser Memorator Pro and TRX.
Said the customer: “I wrote a quick data logging routine that checks for mis-matched BAM packets on the CAN traffic, and when seen, saves data to a buffer.”
With a little help from Kvaser Support, the customer confirmed: “The logger worked exactly as needed … it was much easier than the options we had in the past.”
Example 2: A small company used TRX to develop a t script to replace the vehicle under test, a recreational vehicle in this case, that they had rented for testing purposes but were about to lose.
Specifically, their t script needed to highlight the on/off state of a light when testing a command sent from an iPad. “Can we create a device to monitor the CAN bus and send a specific message when we receive a command?”, they asked. Kvaser helped provide the code for this project, which can be shared and is available here.
Download Example t script >>
variables {
Timer msgTimer01;
Timer msgTimer02;
Timer msgTimer03;
Timer msgTimer11;
const int can_channel = 0;
const int can_bitrate = 250000;
const int Toggle01 = 0x1FEDB9F;
byte status01_byte[8] = {0x01, 0xFF, 0x00, 0xFC, 0xFF, 0x12, 0x00, 0xFE};
byte status02_byte[8] = {0x02, 0xFF, 0x00, 0xFC, 0xFF, 0x12, 0x00, 0xFE};
byte status03_byte[8] = {0x03, 0xFF, 0x00, 0xFC, 0xFF, 0x12, 0x00, 0xFE};
byte status11_byte[8] = {0x11, 0xFF, 0x00, 0xFC, 0xFF, 0x12, 0x00, 0xFE};
int value = 0;
byte instance;
}
on start {
canSetBitrate(can_bitrate);
canBusOn();
msgTimer01.timeout = 2000;
timerStart(msgTimer01, FOREVER);
msgTimer02.timeout = 2000;
timerStart(msgTimer02, FOREVER);
msgTimer03.timeout = 2000;
timerStart(msgTimer03, FOREVER);
msgTimer11.timeout = 2000;
timerStart(msgTimer11, FOREVER);
}
on Timer msgTimer01 {
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status01_byte[value];
}
canWrite(msg);
}
on Timer msgTimer02 {
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status02_byte[value];
}
canWrite(msg);
}
on Timer msgTimer03 {
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status03_byte[value];
}
canWrite(msg);
}
on Timer msgTimer11 {
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status11_byte[value];
}
canWrite(msg);
}
on CanMessage<0> (Toggle01)x {
CanMessage_RVC_DIM_CMD_2 Command_Message;
instance = Command_Message.RVC_DIM_CMD_INST.Raw;
printf("We got a Toggle command for Instance %02x", instance);
if (instance == 0x01) {
if (status01_byte[6] == 0x00) {
status01_byte[6] = 0x04;
status01_byte[1] = 0xC8;
} else {
status01_byte[6] = 0x00;
status01_byte[1] = 0x00;
}
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status01_byte[value];
}
canWrite(msg);
return;
}
else {
if (instance == 0x02) {
if (status02_byte[6] == 0x00) {
status02_byte[6] = 0x04;
status02_byte[1] = 0xC8;
} else {
status02_byte[6] = 0x00;
status02_byte[1] = 0x00;
}
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status02_byte[value];
}
canWrite(msg);
return;
}
else {
if (instance == 0x03) {
if (status03_byte[6] == 0x00) {
status03_byte[6] = 0x04;
status03_byte[1] = 0xC8;
} else {
status03_byte[6] = 0x00;
status03_byte[1] = 0x00;
}
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status03_byte[value];
}
canWrite(msg);
return;
}
else {
if (instance == 0x11) {
if (status11_byte[6] == 0x00) {
status11_byte[6] = 0x04;
status11_byte[1] = 0xC8;
} else {
status11_byte[6] = 0x00;
status11_byte[1] = 0x00;
}
CanMessage msg;
msg.flags = canMSG_EXT;
msg.id = 0x19FEDA01;
msg.dlc = 8;
for(int value = 0; value < 8; value++) {
msg.data[value] = status11_byte[value];
}
canWrite(msg);
return;
}
}
}
}
}
on stop {
canBusOff();
}