CAPL_functions
CAPL_functions
delay(2000);
delay(2000);
delay(3000);
writeDestroy();
}
writeTextBkgColor(color) changes the background color.
writeTextColor(color) changes the text color.
Time Functions
void OnStart() {
setTimer(myTimer, 5000); // Start timer for 5 seconds (5000 ms)
write("Timer started for 5 seconds.");
}
void onTimer(myTimer) {
write("Timer expired!");
cancelTimer(myTimer); // Stop the timer
}
setTimer(myTimer, 5000) starts a timer for 5 seconds.
onTimer(myTimer) executes when the timer expires.
cancelTimer(myTimer) stops the timer.
void OnMessage() {
time1 = timeNow();
delay(3000); // Simulating a delay of 3 seconds
time2 = timeNow();
on start {
logFile = openFile("can_log.txt", O_WRONLY);
}
on message * {
write(logFile, "ID: 0x%X, Data: %X %X %X %X %X %X %X %X",
this.ID, this.byte(0), this.byte(1), this.byte(2),
this.byte(3), this.byte(4), this.byte(5), this.byte(6), this.byte(7));
}
on stop {
closeFile(logFile);
}
on message * {
msgCount++;
write("Message Count: %d, Latest ID: 0x%X", msgCount, this.ID);
}
on start {
num = atol(strNum);
write("Converted Number: %d", num);
}
on start {
snprintf(buffer, sizeof(buffer), "Year: %d", value);
write("Formatted String: %s", buffer);
}
on start {
length = strlen(myString);
write("String Length: %d", length);
}
on start {
strncat(str1, str2, sizeof(str1) - strlen(str1) - 1);
write("Concatenated String: %s", str1);
}
on start {
result = strncmp(str1, str2, 4);
if (result == 0) {
write("Strings are equal");
} else {
write("Strings are different");
}
}
on start {
strncpy(destination, source, sizeof(destination) - 1);
destination[sizeof(destination) - 1] = '\0'; // Null-terminate manually
write("Copied String: %s", destination);
}