unit CANlibD; (*---------------------------------------------------------------------------- | File: | CANlibD.pas | Project: | Unit for Delphi32 samples (V2.0) | |----------------------------------------------------------------------------- | Ported from cantrace.c by Torsten Lang |----------------------------------------------------------------------------- | Copyright (c) 1998 BSK Datentechnik GmbH, Kiesacker 14, 35418 Buseck / | 1998 by Vector Informatik GmbH, Friolzheimer Str. 6, 70499 Stuttgart | All rights reserved. | | BSK Datentechnik räumt der Vector Informatik GmbH das nicht ausschließliche Recht | ein, CANlibD.pas für eigene Zwecke zu nutzen. Vector ist es gestattet, die | Software zu kopieren, abzuändern, zu erweitern, weiterzugeben und in Software von | Vector zu integrieren. Im Quelltext enthaltene Copyright-Hinweise dürfen hierbei | nicht entfernt oder geändert werden. | Vector darf aus von ihm vorgenommenen Anpassungen und/oder Erweiterungen der | CANlibD.pas keine Rechte an irgendwelchen Teilen der Software gegenüber BSK | Datentechnik geltend machen. ----------------------------------------------------------------------------*) { environment switches } (******************************************************************************* Attention: 1. All functions that use pointers to structures (either explicitly or by using var parameters) may change the contents of the structures right after the funtction returns. *******************************************************************************) {$ifdef WIN32} {$define CanLib4Delphi32} {$else} {$ifdef CONSOLE} {$define CanLib4Delphi32} {$endif} {$endif} { public interface } interface type ncdStringType = PChar; Vstatus = Word; const MAX_APPNAME = 32; VCAN_WAIT = 0; VCAN_POLL = 1; {$ifdef CanLib4Delphi32} { Attention: This exists only under Win32 } VCAN_NOTIFY = 2; {$endif} VSUCCESS = 0; VPENDING = 1; VERROR = 255; VERR_QUEUE_IS_EMPTY = 10; VERR_QUEUE_IS_FULL = 11; VERR_TX_NOT_POSSIBLE = 12; VERR_NO_LICENSE = 14; VERR_WRONG_PARAMETER = 101; VERR_TWICE_REGISTER = 110; VERR_INVALID_CHAN_INDEX = 111; VERR_INVALID_ACCESS = 112; VERR_PORT_IS_OFFLINE = 113; VERR_CHAN_IS_ONLINE = 116; VERR_INVALID_PORT = 118; VERR_HW_NOT_READY = 120; VERR_CMD_TIMEOUT = 121; VERR_HW_NOT_PRESENT = 129; VERR_NOTIFY_ALREADY_ACTIVE = 131; VERR_CANNOT_OPEN_DRIVER = 201; { //------------------------------------------------------------------------------ // accessmask } type Vaccess = LongInt; { unsigned long doesn't exist for Delphi32 / Borland Pascal 7! } { //------------------------------------------------------------------------------ // porthandle } const INVALID_PORTHANDLE = -1; type VportHandle = LongInt; { //------------------------------------------------------------------------------ // acceptance filter } type VsetAcceptance = packed record code : LongInt; {unsigned long doesn't exist!} mask : LongInt; {unsigned long doesn't exist!} end; PVsetAcceptance = ^VsetAcceptance; { //------------------------------------------------------------------------------ // bit timing } type VchipParams = packed record bitRate : LongInt; {unsigned long doesn't exist!} sjw : Byte; tseg1 : Byte; tseg2 : Byte; sam : Byte; { 1 or 3 } end; PVchipParams = ^VchipParams; { //------------------------------------------------------------------------------ // definitions for the events and commands used by the driver } const V_RECEIVE_MSG = 1; V_CHIP_STATE = 4; V_CLOCK_OVERFLOW = 5; V_TRIGGER = 6; V_TIMER = 8; V_TRANSCEIVER = 9; V_TRANSMIT_MSG = 10; type VeventTag = Byte; { //------------------------------------------------------------------------------ // events } { //------------------------------------------------------------------------------ // structure for V_RECEIVE_MSG } const MAX_MSG_LEN = 8; EXT_MSG = $80000000; { signs an extended identifier } MSGFLAG_ERROR_FRAME = $01; { Msg is a bus error } MSGFLAG_OVERRUN = $02; { Msgs following this has been lost } MSGFLAG_NERR = $04; { NERR active during this msg } MSGFLAG_WAKEUP = $08; { Msg rcv'd in wakeup mode } MSGFLAG_REMOTE_FRAME = $10; { Msg is a remote frame } MSGFLAG_RESERVED_1 = $20; { Reserved for future usage } MSGFLAG_TX = $40; { TX acknowledge } MSGFLAG_TXRQ = $80; { TX request } type _Vmsg = packed record id : LongInt; {unsigned long doesn't exist!} flags : Byte; dlc : Byte; data : array [0..MAX_MSG_LEN-1] of Byte; end; { 14 Bytes } _PVmsg = ^_Vmsg; { // structure for V_CHIP_STATE } const CHIPSTAT_BUSOFF = $01; CHIPSTAT_ERROR_PASSIVE = $02; CHIPSTAT_ERROR_WARNING = $04; CHIPSTAT_ERROR_ACTIVE = $08; type _VchipState = packed record busStatus : Byte; txErrorCounter : Byte; rxErrorCounter : Byte; end; _PVchipState = ^_VchipState; { // structure for V_TRANSCEIVER } const TRANSCEIVER_EVENT_ERROR = 1; TRANSCEIVER_EVENT_CHANGED = 2; TRANSCEIVER_TYPE_NONE = 0; TRANSCEIVER_TYPE_251 = 1; TRANSCEIVER_TYPE_252 = 2; TRANSCEIVER_TYPE_DNOPTO = 3; TRANSCEIVER_TYPE_W210 = 4; TRANSCEIVER_LINEMODE_NA = 0; TRANSCEIVER_LINEMODE_TWO_LINE = 1; TRANSCEIVER_LINEMODE_CAN_H = 2; TRANSCEIVER_LINEMODE_CAN_L = 3; TRANSCEIVER_RESNET_NA = 0; TRANSCEIVER_RESNET_MASTER = 1; TRANSCEIVER_RESNET_MASTER_STBY = 2; TRANSCEIVER_RESNET_SLAVE = 3; type _Vtransceiver = packed record event : Byte; { TRANSCEIVER_EVENT_xxx } end; _PVtransceiver = ^_Vtransceiver; Vevent = packed record tag : VeventTag; { 1 } chanIndex : Byte; { 1 } _transId : Byte; { 1 not implemented yet !!!! } portHandle : Byte; { 1 internal use only !!!! } timeStamp : LongInt; { 4 } { unsigned long doesn't exist! } case {tagData:}Byte of 0 : (msg : _Vmsg); 1 : (chipState : _VchipState); 2 : (transceiver : _Vtransceiver); { 14 Bytes (_VMessage) } end; { -------- } { 22 Bytes } PVevent = ^Vevent; { //------------------------------------------------------------------------------ // structure for SET_OUTPUT_MODE } const OUTPUT_MODE_SILENT = 0; OUTPUT_MODE_NORMAL = 1; { //------------------------------------------------------------------------------ // configuration } { // defines for the supported hardware } const HWTYPE_NONE = 0; HWTYPE_VIRTUAL = 1; HWTYPE_CANCARDX = 2; HWTYPE_CANPARI = 3; HWTYPE_CANDONGLE = 4; HWTYPE_CANAC2 = 5; HWTYPE_CANAC2PCI = 6; HWTYPE_CANCARD = 7; HWTYPE_CANCARDY = 12; HWTYPE_CANCARDXL = 15; HWTYPE_CANCARD2 = 17; HWTYPE_EDICCARD = 19; HWTYPE_CANCASEXL = 21; HWTYPE_CANBOARDXL = 25; HWTYPE_CANBOARDXL_COMPACT = 27; MAX_HWTYPE = 27; { // defines for the tranceiver type } const (* TRANSCEIVER_TYPE_NONE = 0; TRANSCEIVER_TYPE_251 = 1; TRANSCEIVER_TYPE_252 = 2; TRANSCEIVER_TYPE_DNOPTO = 3; TRANSCEIVER_TYPE_W210 = 4; *) { These have already been defined above } MAX_TRANSCEIVER_TYPE = 4; MAX_CHAN_NAME = 31; MAX_DRIVER_NAME = 31; type VChannelConfig = packed record name : array [0..MAX_CHAN_NAME] of Char; hwType : Byte; { HWTYPE_xxxx (see above) } hwIndex : Byte; { Index of the hardware (same type) (0,1,...) } hwChannel : Byte; { Index of the channel (same hardware) (0,1,...) } tranceiverType : Byte; { TRANCEIVER_TYPE_xxxx (see above) } channelIndex : Byte; { Global channel index (0,1,...) } channelMask : LongInt; { Global channel mask (=1<