unit impcanlib;

(* Unité d'import du driver PCANLIB *)

interface

{$I ERR_CODE_IOLIB.PAS}
  Err_DriverRunning = -1;
  Err_DriverStopped = -2;
  Err_IOLibNotFound = -3;
  Err_CANBoardNotFound = -4;
  Err_CANActive = -5;
  Err_CANInactive = -6;
  Err_WinRessource = -7;
  Err_RXQueueOverflow = -8;
  Err_TXQueueOverflow = -9;

Type
  TMessageCAN = Record
    Descripteur : Word;
    Donnees : Array [1..8] of Byte;
  End;
  PMessageCAN = ^TMessageCAN;

Function OpenDriver (BasePort : Word; DriverName : PChar) : Integer; StdCall;
Procedure CloseDriver; StdCall;
Function SetCANFilter (ACAM : Word) : Integer; StdCall;
Function SetCANTiming (BTVal : Word) : Integer; StdCall;
Function StartCAN : Integer; StdCall;
Function StopCAN : Integer; StdCall;
Function GetCANMessage (CANMsg : PMessageCAN) : Integer; StdCall;
Function SendCANMessage (CANMsg : PMessageCAN; ViaRing : Word) : Integer; StdCall;
Function AbortCANTransmission : Integer; StdCall;
Function GetCANStatus : Word; StdCall;

implementation

Function OpenDriver; External 'PCANLIB' Index 1;
Procedure CloseDriver; External 'PCANLIB' Index 2;
Function SetCANFilter; External 'PCANLIB' Index 3;
Function SetCANTiming; External 'PCANLIB' Index 4;
Function StartCAN; External 'PCANLIB' Index 5;
Function StopCAN; External 'PCANLIB' Index 6;
Function GetCANMessage; External 'PCANLIB' Index 7;
Function SendCANMessage; External 'PCANLIB' Index 8;
Function AbortCANTransmission; External 'PCANLIB' Index 9;
Function GetCANStatus; External 'PCANLIB' Index 10;

end.
