Kvaser Linux CANLIB
|
Let's start with a simple example.
#include <canlib.h> #include <stdio.h> void main(void) { canHandle h; canInitializeLibrary(); h = canOpenChannel(0, canOPEN_EXCLUSIVE); if (h < 0) { char msg[64]; canGetErrorText((canStatus)h, msg, sizeof(msg)); fprintf(stderr, "canOpenChannel failed (%s)\n", msg); exit(1); } canSetBusParams(h, BAUD_250K, 0, 0, 0, 0, 0); canSetBusOutputControl(h, canDRIVER_NORMAL); canBusOn(h); canWrite(h, 123, "HELLO!", 6, 0); canWriteSync(h, 500); canBusOff(h); canClose(h); }
What does it do?
What does it not do? Almost all error checking is omitted for brevity.