The information in this document is subject to change without prior
notice in order to improve reliability, design, and function and does
not represent a commitment on the part of the manufacturer.
In no event will the manufacturer be liable for direct, indirect, special, incidental, or consequential damages arising out of the use or
inability to use the product or documentation, even if advised of
the possibility of such damages.
This document contains proprietary information protected by copyright. All rights are reserved. No part of this manual may be reproduced by any mechanical, electronic, or other means in any form
without prior written permission of the manufacturer.
Trademarks
NuDAQ, NuIPC, DAQBench are registered trademarks of ADLINK
TECHNOLOGY INC.
Product names mentioned herein are used for identification purposes only and may be trademarks and/or registered trademarks
of their respective companies.
Page 3
Getting Service from ADLINK
Customer Satisfaction is top priority for ADLINK Technology Inc.
Please contact us should you require any service or assistance.
ADLINK TECHNOLOGY INC.
Web Site:http://www.adlinktech.com
Sales & Service:Service@adlinktech.com
TEL:+886-2-82265877
FAX:+886-2-82265717
Address:9F, No. 166, Jian Yi Road, Chungho City,
Taipei, 235 Taiwan
Please email or FAX this completed service form for prompt and
satisfactory service.
Company Information
Company/Organization
Contact Person
E-mail Address
Address
Country
TELFAX:
Web Site
Product Information
Product Model
OS:
Environment
M/B: CPU:
Chipset: BIOS:
Please give a detailed description of the problem(s):
Page 4
Page 5
Table of Contents
Table of Contents..................................................................... i
List of Tables.......................................................................... iii
List of Figures ........................................................................ iv
The PCI/cPCI/PM-7841 is a Controller Area Network (CAN) interface card used for industrial PC with PCI, Compact-PCI, and
PC104 bus. It supports dual ports CAN’s interface that can run
independently or bridged at the same time. The built-in CAN controller provides bus arbitration and error detection with auto correction and re-transmission function. The PCI cards are plug and
play therefore it is not necessary to set any jumper for matching
the PC environment.
The CAN (Controller Area Network) is a serial bus system originally developed by Bosch for use in automobiles, is increasing
being used in industry automation. It multi-master protocol, realtime capability, error correction and high noise immunity make it
especially suited for intelligent I/O devices control network.
The PCI/cPCI/PM-7841 is programmed by using the ADLINK‘s
software library. The programming of this PCI card is as easy as
AT bus add-on cards.
1.1PCI/cPCI/PM-7841 Features
The PCI-7841 is a Dual-Port Isolated CAN Interface Card with the
following features:
X Two independent CAN network operation
X Bridge function supports
X Compatible with CAN specification 2.0 parts A and B
X Optically isolated CAN interface up to 2500 Vrms isolation
protection
X Direct memory mapping to the CAN controllers
X Powerful master interface for CANopen, DeviceNet and
SDS application layer protocol
X Up to 1Mbps programmable transfer rate
X Supports standard DeviceNet data rates 125, 250 and 500
Kbps
X PCI bus plug and play
X DOS library and examples included
Introduction 1
Page 10
The cPCI-7841 is a Dual-Port Isolated CAN Interface Card with
the following features:
X Two independent CAN network operation
X Bridge function supports
X Compatible with CAN specification 2.0 parts A and B
X Optically isolated CAN interface up to 2500 Vrms isolation
protection
X Direct memory mapping to the CAN controllers
X Powerful master interface for CANopen, DeviceNet and
SDS application layer protocol
X Up to 1Mbps programmable transfer rate
X Supports standard DeviceNet data rates 125, 250 and 500
Kbps
X PCI bus plug and play
X compact-PCI industry bus
X DOS library and examples included
The PM-7841 is a Dual-Port Isolated CAN Interface Card with the
following features:
X Two independent CAN network operation
X Bridge function supports
X Compatible with CAN specification 2.0 parts A and B
X Optically isolated CAN interface up to 2500 Vrms isolation
protection
X Direct memory mapping to the CAN controllers
X Powerful master interface for CANopen, DeviceNet and
SDS application layer protocol
X Up to 1Mbps programmable transfer rate
X Supports standard DeviceNet data rates 125, 250 and 500
Kbps
X DIP-Switch for base address configuration
X Software Programmable Memory-Mapped Address
X PC-104 industry form factor
X DOS library and examples included
2Introduction
Page 11
1.2Applications
X Industry automation
X Industry process monitoring and control
X Manufacture automation
X Product testing
Introduction 3
Page 12
1.3Specifications
PCI-7841 Specification Table
Ports2 CAN channels (V2.0 A,B)
CAN ControllerSJA1000
CAN Transceiver82c250
Signal SupportCAN_H, CAN_L
Isolation Voltage2500 Vrms
ConnectorsDual DB-9 male connectors
Operation Temperature
Storage Temperature
Humidity5% ~ 95% non-condensing
IRQ LevelSet by Plug and Play BIOS
I/O port addressSet by Plug and Play BIOS
Power Consumption
(without external devices)
Size132(L)mm x 98(H)mm
Table 1-1: PCI-7841 Specifications
cPCI-7841 Specification Table
Ports2 CAN channels (V2.0 A,B)
CAN ControllerSJA1000
CAN Transceiver82c250
Signal SupportCAN_H, CAN_L
Isolation Voltage2500 Vrms
ConnectorsDual male connectors
Operation Temperature
Storage Temperature
Humidity5% ~ 95% non-condensing
IRQ LevelSet by Plug and Play BIOS
I/O port addressSet by Plug and Play BIOS
Power Consumption
(without external devices)
Table 1-2: cPCI-7841 Specifications
0 ~ 60
°C
-20°C ~ 80°C
400mA @5VDC ( Typical)
900mA @5VDC ( Maximum)
0 ~ 60
°C
-20
°C ~ 80°C
400mA @5VDC ( Typical)
900mA @5VDC ( Maximum)
4Introduction
Page 13
Size132(L)mm x 98(H)mm
Table 1-2: cPCI-7841 Specifications
PM-7841 Specification Table
Ports2 CAN channels (V2.0 A,B)
CAN ControllerSJA1000
CAN Transceiver82c250/82c251
Signal SupportCAN_H, CAN_L
Isolation Voltage1000 Vrms
ConnectorsDual 5 male connectors
Operation Temperature
Storage Temperature
Humidity5% ~ 95% non-condensing
IRQ LevelSet by Jumper
I/O port addressSet by DIP Switch
Memory Mapped Space128 Bytes by Software
Power Consumption
(without external devices)
Size90.17(L)mm x 95.89(H)mm
Table 1-3: PM-7841 Specifications
0 ~ 60
°C
-20
°C ~ 80°C
400mA @5VDC ( Typical)
900mA @5VDC ( Maximum)
Introduction 5
Page 14
6Introduction
Page 15
2Installation
This chapter describes how to install the PCI/cPCI/PM-7841. At
first, the contents in the package and unpacking information that
you should be careful are described.
2.1Before Installing the PCI/cPCI/PM-7841
Your PCI/cPCI/PM-7841 card contains sensitive electronic components that can be easily damaged by static electricity.
The card should be done on a grounded anti-static mat. The operator should be wearing an anti-static wristband, grounded at the
same point as the anti-static mat.
Inspect the card module carton for obvious damage. Shipping and
handling may cause damage to your module. Be sure there are no
shipping and handing damages on the module before processing.
After opening the card module carton, exact the system module
and place it only on a grounded anti-static surface component side
up.
Note:DO NOT APPLY POWER TO THE CARD IF IT HAS BEEN
DAMAGED.
You are now ready to install your PCI/cPCI/PM-7841.
2.2Installing PCI-7841
What you have:
In addition to this User's Manual, the package includes the following items:
X PCI-7841 Dual Port PCI Isolated CAN Interface Card
X ADLINK CD-ROM
If any of these items is missing or damaged, contact the dealer
from whom you purchased the product. Save the shipping materials and carton in case you want to ship or store the product in the
future.
Installation 7
Page 16
PCI-7841 Layout:
Terminator Configuration
A 120 Ohm terminal resistor is installed for each port, while JP1
enables the terminal resistor for port0 and JP2 enables the terminal resistor for port 1
Connector Pin Definition
P3 and P4 are CAN connectors; pin definition is as follows:
8Installation
Page 17
2.3Installing cPCI-7841
What you have
In addition to this User's Manual, the package includes the following items:
X cPCI-7841 Dual Port Compact-PCI Isolated CAN Interface
Card
X ADLINK CD-ROM
If any of these items is missing or damaged, contact the dealer
from whom you purchased the product. Save the shipping materials and carton in case you want to ship or store the product in the
future.
cPCI-7841 Layout
Terminator Configuration
A 120 Ohm terminal resistor is installed for each port, while JP1
enables the terminal resistor for port0 and JP2 enables the terminal resistor for port 1
Installation 9
Page 18
Connector Pin Definition
J1 and J2 are CAN connectors; pin definition is as follows:
2.4Installing PM-7841
What you have
In addition to this User's Manual, the package includes the following items:
X PM-7841 Dual Port PC-104 Isolated CAN Interface Card
X ADLINK CD-ROM
If any of these items is missing or damaged, contact the dealer
from whom you purchased the product. Save the shipping materials and carton in case you want to ship or store the product in the
future.
10Installation
Page 19
PM-7841 Layout
Terminator Configuration
A 120 Ohm terminal resistor is installed for each port, while JP1
enables the.
terminal resistor for port0 and JP2 enables the terminal resistor for
port 1.
Installation 11
Page 20
Connector Pin Define
J1 and J2 are CAN connectors; pin definition is as follows:
2.5Jumper and DIP Switch Description
You can configure the output of each channel and base address
by setting jumpers and DIP switches on the PM-7841. The card's
jumpers and switches are preset at the factory. Under normal circumstances, you should not need to change the jumper settings.
A jumper switch is closed (sometimes referred to as "shorted")
with the plastic cap inserted over two pins of the jumper. A jumper
is open with the plastic cap inserted over one or no pin(s) of the
jumper.
2.6Base Address Setting
The PM-7841 requires 16 consecutive address locations in I/O
address space. The base address of the PM-7841 is restricted by
the following conditions.
1. The base address must be within the range 200hex to
3F0hex.
2. The base address should not conflict with any PC
reserved I/O address.
The PM-7841's I/O port base address is selectable by an 5 position DIP switch SW1 ( refer to Table 2.1). The address settings for
I/O port from Hex 200 to Hex 3F0 is described in Table 2.2 below.
The default base address of your PM-7841 is set to hex 200 in the
factory( see Figure below).
12Installation
Page 21
SW1 : Base Address = 0x200
ON
12345
A ( 8 7 6 5 4 )
Figure 2-1: Default Base Address Configuration
(*): default setting ON: 0
X: don't careOFF: 1
Note: A4,…, A9 correspond to PC-104(ISA) bus address lines.
Installation 13
Page 22
2.7IRQ Level Setting
A hardware interrupt can be triggered by the external Interrupt signal which is from JP3 ad JP4.
The jumper setting is specified as below:
Note:Be aware that there is no other add-on cards sharing the
same interrupt level in the system.
Interrupt Default Setting = IRQ15
(IRQ)
X 15 12 11 10
Figure 2-2: IRQ Settings
9 7 6 5 3
14Installation
Page 23
3Function Reference
The cPCI/PCI-7841 functions are organize into the following sections:
X CAN layer functions
X Card Initialization and configuration functions
X CAN layer I/O functions
X CAN layer status functions
X CAN layer Error and Event Handling functions
X DeviceNet layer functions
X Send and Receive packet functions
X Connection establish and release functions
X DeviceNet object class functions
The particular functions associated with each function are presented in next page.
3.1Functions Table
CAN layer functions
Function TypeFunction Name
PM-7841 InitialPM7841_Install()
GetDriverVersion()
CanOpenDriver()
CanCloseDriver()
CanConfigPort()
CanDetectBaudrate()
_7841_Read()
_7841_Write()
CanEnableReceive()
CanDisableReceive()
CanSendMsg()
CanRcvMsg()
CanGetRcvCnt()
Function Reference 15
Page 24
CanClearOverrun()
CanClearRxBuffer()
CanClearTxBuffer()
CanGetErrorCode()
CanGetErrorWarningLimit()
CanSetErrorWarningLimit()
CanGetRxErrorCount()
CanGetTxErrorCount()
CanSetTxErrorCount()
CanGetPortStatus()
CanGetLedStatus()1
CanSetLedStatus()1
Error and Event handling functions
Operation SystemFunction Name
DOS
Windows 95/98/NTCanInstallEvent()
CanInstallCallBack()
CanRemoveCallBack()
Note:only for compact PCI and PC-104 version.
PORT_STRUCT structure define
The PORT_STRUCT structure defines the mode of id-mode,
acceptance code, acceptance mask and baud rate of a physical
CAN port. It is used by the CanPortConfig(), and CanGetPortStatus() functions.
typedef struct _tagPORT_STRUCT
{
int mode; // 0 for 11-bit; 1 for 29-
bit
DWORD accCode, accMask;
int baudrate;
BYTE brp, tseg1, tseg2;// Reserved
BYTE sjw, sam; // Reserved
}PORT_STRUCT;
16Function Reference
Page 25
Members
mode: 0 means using 11-bit in CAN-ID field
1 means using 29-bit in CAN-ID field.
accCode:Acceptance Code for CAN controller.
accMask:Acceptance Mask for CAN controller.
baudrate:Baud rate setting for the CAN controller.
Value Baudrate
0125 Kbps
1250 Kbps
2500 Kbps
31M bps
CanPortConfig(), CanGetPortStatus(), and PORT_STATUS structure
PORT_STATUS structure define
The PORT_STATUS structure defines the status register and
PORT_STRUCT of CAN port. It is used by the CanGetPortStatus()
functions.
typedef struct _tagPORT_STATUS
{
PORT_STRUCT port;
PORT_REG status;
}PORT_STATUS;
Members
port:PORT_STRUCT data
status:status is the status register
mapping of CAN controller.
typedef union _tagPORT_REG
{
struct PORTREG_BIT bit;
unsigned short reg;
}PORT_REG;
struct PORTREG_BIT
{
unsigned short RxBuffer: 1;
unsigned short DataOverrun: 1;
unsigned short TxBuffer: 1;
Function Reference 17
Page 26
unsigned short TxEnd: 1;
unsigned short RxStatus: 1;
unsigned short TxStatus: 1;
unsigned short ErrorStatus: 1;
unsigned short BusStatus: 1;
unsigned short reserved: 8;
};
See Also
CanGetPortStatus(), and PORT_STATUS structure
CAN_PACKET structure define
The CAN_PACKET structure defines the packet format of CAN
packet. It is used by the CanSendMsg(), and CanRcvMsg() functions.
PurposeGet the version of driver
PrototypeC/C++
int PM7841_Install(int baseAddr, int irq_chn, int memorySpace)
ParametersbaseAddr:Base Address of PM-7841(DIP
Switch)
Irq_chn:IRQ channel (Jumpper)
MemorySpace:Memory Mapping Range
Return ValueA signed integer
0 : Successful
-1: Failed
RemarksPM7841 is PC104(ISA) CAN interface card.
It will need 32-bytes I/O space and 1K
memory space.
See Alsonone
UsageC/C++
#include “pm7841.h”
int ret;
ret = PM7841_Install(
baseAddr,
irq_ch,
memorySpace);
GetDriverVersion()
PurposeGet the version of driver
PrototypeC/C++
WORD GetDriverVersion(void)
Parametersnone
Return ValueA 16-bit unsigned integer
High byte is the major version
Low byte is the major version
20Function Reference
Page 29
RemarksCall this function to retrieve the version of
current using driver. This function is for your
program to get the version of library and
dynamic-linked library.
See Alsonone
UsageC/C++
#include “pci7841.h”
WORD version = GetDriverVersion();
majorVersion = version >> 8;
minorVersion = version & 0x00FF;
CanOpenDriver()
PurposeOpen a specific port, and initialize driver.
PrototypeC/C++
int CanOpenDriver(int card, int port))
Parameterscard:index of card
port:index of port
Return ValueReturn a handle for open port
-1 if error occurs
RemarksCall this function to open a port
Under DOS operation system, you will
receive –1 if there is not enough memory. If
writing program for the Windows system. It
will return -1, if you want to open a port had
been opened. And you must use Can-
CloseDriver() to close the port after using.
See AlsoCanCloseDriver()
UsageC/C++
#include “pci7841.h”
int handle = CanOpenDriver();
CanSendMsg(handle, &msg);
CanCloseDriver(handle);
CanCloseDriver()
PurposeClose an opened port, and release driver.
PrototypeC/C++
int CanCloseDriver(int handle)
Function Reference 21
Page 30
Parametershandle : handle retrieve from CanOpen-
Driver()
Port : index of port
Return ValueReturn 0 if successful
-1 if error occurs
RemarksCall this function to close a port.
See AlsoCanOpenDriver()
UsageSee usage of CanOpenDriver().
CanConfigPort()
PurposeConfigure properties of a port
PrototypeC/C++
int CanConfigPort(int handle,
PORT_STRUCT *ptrStruct)
Parametershandle : handle retrieve from CanOpen-
Driver()
PtrStruct : a pointer of PORT_STRUCT
type
Return ValueReturn 0 is successful
-1 if error occurs
RemarksConfigure a port that had been opened.
The properties of a CAN port such as baud
rate, acceptance code, acceptance mask,
operate mode. After configuration is over,
the port is ready to send and receive data.
See AlsoPORT_STRUCT structure define
UsageC/C++
#include “pci7841.h
PORT_STRUCT port_struct;
int handle = CanOpenDriver(0, 0);//Open port 0 of
card 0
port_struct.mode = 0;//CAN2.0A (11-bit CAN id)
port_struct.accCode = 0;//This setting of
acceptance code and
port_struct.accMask = 0x7FF; //mask enable all
PurposeDirect read the register of PCI-7841.
PrototypeC/C++
BYTE CanRead(int handle, int offset)
Parametershandle : handle retrieve from CanOpen-
Driver()
offset : offset of register
Return ValueReturn data read from port.
RemarksDirect read the register of PCI-7841.
See AlsoCanWrite()
Usagenone
CanWrite()
PurposeDirect write the register of PCI-7841.
PrototypeC/C++
void CanWrite(int handle, int offset, BYTE
data)
Parametershandle : handle retrieve from CanOpen-
Driver()
Offset : offset of register
data : data write to the port
Return Valuenone
RemarksCall this function to directly write a register
of PCI-7841
See AlsoCanRead()
Usagenone
CAN-layer I/O Functions
CanEnableReceive()
PurposeEnable receive of a CAN port.
PrototypeC/C++
24Function Reference
Page 33
void CanEnableReceive(int handle);
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuenone
RemarksCall this function to enable receive.
Any packet on the network that can induce
a interrupt on your computer. If that packet
can pass your acceptance code and accep-
tance mask setting. So if your program
doesn’t want to be disturbed. You can call
CanDisableReceive() to disable receive
and CanEnableReceive() to enable
receives.
See AlsoCanDisableReceive()
Usagenone
CanDisableReceive()
PurposeDisable receive of a CAN port.
PrototypeC/C++
void CanEnableReceive(int handle);
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuenone
RemarksPlease refer the CanEnableReceive()
See AlsoCanEnableReceive()
Usagenone
CanSendMsg()
PurposeSend can packet to a port
PrototypeC/C++
int CanSendMsg(int handle, CAN_PACKET
*packet);
Parametershandle : handle retrieve from CanOpen-
Driver()
Packet : CAN_PACKET data
Return ValueReturn 0 is successful
Function Reference 25
Page 34
-1 if error occurs
RemarksSend a message to an opened CAN port.
Actually, this function copies the data to the
sending queue. Error occurs when the port
has not been opened yet or the packet is a
NULL pointer. You can use the Error and
Event handling functions to handle the
exceptions.
See AlsoCanRcvMsg()
UsageC/C++
#include “pci7841.h
PORT_STRUCT port_struct;
CAN_PACKET sndPacket, rcvPacket;
int handle = CanOpenDriver(0, 0);//open the port
PurposeReceive a can packet from a port
PrototypeC/C++
int CanSendMsg(int handle, CAN_PACKET
*packet);
Parametershandle : handle retrieve from CanOpen-
Driver()
Packet : CAN_PACKET data
Return ValueReturn 0 is successful
-1 if error occurs
RemarksReceive a message from an opened CAN
port.
There are only 64-bytes FIFO under hard-
ware. It can store from 3 to 21 packets. So
there are memory buffer under driver. When
data comes, the driver would move it from
26Function Reference
Page 35
card to memory. It starts after your port configuration is done. This function copies the
buffer to your application. So if your program has the critical section to process the
data on the network. We suggest that you
can call the CanClearBuffer() to clear the
buffer first. Error would be happened most
under the following conditions:
1. You want to access a port that has not be
opened.
2. Your packet is a NULL pointer.
3. The receive buffer is empty.
You can use the Status handling functions
to handle the exceptions.
See AlsoCanSendMsg()
UsageSee the CanSendMsg()
CAN-layer Status Functions
CanClearOverrun()
PurposeClear data overrun status
PrototypeC/C++
void CanClearOverrun(int handle)
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuenone
RemarksClear the data overrun status
Sometimes if your system has heavy load,
and the bus is busy. The data overrun
would be signalled. A Data Overrun signals,
that data are lost, possibly causing incon-
sistencies in the system.
See AlsoCanRcvMsg()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
PurposeClear data in the receive buffer
PrototypeC/C++
void CanClearRxBuffer(int handle)
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuenone
RemarksClear the data in the receive buffer
There are 2-type of buffer defined in the
driver. First one is the FIFO in the card, the
second one is the memory space inside the
driver. Both of them would be cleared after
using this function.
See AlsoCanRcvMsg()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
CanClearRxBuffer(handle);
CanCloseDriver(handle);
CanClearTxBuffer()
PurposeClear Transmit Buffer
PrototypeC/C++
void CanClearTxBuffer(int handle)
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuenone
RemarksClear the data in the transmit buffer.
Under a busy DeviceNet Network, your
transmit request may not be done due to
the busy in the network. The hardware will
send it automatically when bus is free. The
28Function Reference
Page 37
un-send message would be stored in the
memory of the driver. The sequence of outgoing message is the FIRST-IN-FIRSTOUT. According this algorithm, if your program need to send an emergency data, you
can clear the transmit buffer and send it
again.
See AlsoCanRcvMsg()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
CanClearTxBuffer(handle);
CanCloseDriver(handle);
CanGetErrorCode()
PurposeGet the Error Code
PrototypeC/C++
BYTE CanGetErrorCode(int handle)
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valueerror code
Return error code is an 8-bit data
Bit SymbolNameValueFunction
7 ERRC1 Error Code 1
6 ERRC0 Error Code 0
5DIRDirection
4SEG4Segment 4
3SEG3Segment 3
2SEG2Segment 2
1SEG1Segment 1
0SEG0Segment 0
Function Reference 29
1Rx error occurred during reception
0Tx error occurred during ransmission
Page 38
Bit interpretation of ERRC1 and ERRC2
Bit ERRC1 Bit ERRC2Function
00bit error
01form error
10stuff error
11other type of error
Bit interpretation of SEG4 to SEG 0
SEG4 SEG3 SEG2 SEG1 SEG0Function
00011 start of frame
00010 ID.28 to ID.21
00110 ID.20 to ID.18
00100bit SRTR
00101bit IDE
00111 ID.17 to ID.13
01111 ID.12 to ID.5
01110ID.4 to ID.0
01100RTR bit
01101 reserved bit 1
01001 reserved bit 0
01011Data length code
01010Data field
01000 CRC sequence
11000 CRC delimiter
11001acknowledge slot
11010 end of frame
10010 intermission
10001 active error flag
10110passive error flag
10011tolerate dominant bits
10111 error delimiter
11100 overload flag
30Function Reference
Page 39
RemarksGet the information about the type and
location of errors on the bus.
When a bus error occurs, if your program
installed the call-back function or error-handling event. The error-bit position would be
captured into the card. The value would be
fixed in the card until your program read it
back.
See AlsoCanGetErrorWarningLimit(),
CanSetErrorWarningLimit()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
BYTE data = CanGetErrorCode();
CanCloseDriver(handle);
Driver()
Return Value0-255 (Error warning limit value)
RemarksGet the error warning limit
See AlsoCanSetErrorWarningLimit()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
BYTE limit = CanClearOverrun(handle);
CanCloseDriver(handle);
CanGetRxErrorCount()
PurposeGet the current value of the receive error
counter
PrototypeC/C++
BYTE CanGetRxErrorCount(int handle)
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuevalue
RemarksThis function reflects the current of the
receive error counter. After hardware reset
happened, the value returned would be ini-
tialized to 0. If a bus-off event occurs, the
returned value would be 0.
See AlsoCanRcvMsg()
UsageC/C++
32Function Reference
Page 41
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
BYTE error_count = CanGetRxErrorCount();
CanCloseDriver(handle);
CanGetTxErrorCount()
PurposeGet the current value of the transmit error
counter
PrototypeC/C++
BYTE CanGetTxErrorCount(int handle)
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuevalue
RemarksThis function reflects the current of the
transmit error counter. After hardware reset
happened, the value would set to 127. A
bus-off event occurs when the value
reaches 255. You can call the CanSetTxEr-
rorCount() to set the value from 0 to 254 to
clear the bus-off event.
See AlsoCanRcvMsg()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
BYTE error_count = CanGetTxErrorCount(handle);
CanCloseDriver(handle);
CanSetTxErrorCount()
PurposeSet the current value of the transmit error
counter
PrototypeC/C++
void CanSetTxErrorCount(int handle, BYTE
value)
Function Reference 33
Page 42
Parametershandle : handle retrieve from CanOpen-
Driver()
value : a byte value
Return ValueNone
RemarksThis function set the current of the transmit
error counter.
Please see the remark of CanGetTxError-
Count().
See AlsoCanRcvMsg()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
CanSetTxErrorCount(handle, 0);
CanCloseDriver(handle);
CanGetPortStatus()
PurposeGet Port Status
PrototypeC/C++
int CanGetPortStatus(int handle,
PORT_STATUS *PortStatus)
Parametershandle : handle retrieve from CanOpen-
Driver()
PortStatus : Pointer of PORT_STATUS
structure
Return ValueNo Error: 0
Error: -1
RemarksGet Port Status(See the structure define for
detailed description)
See Also
UsageC/C++
#include “pci7841.h
PORT_STATUS port_status;
int handle = CanOpenDriver(0, 0);// open the port
0 of card 0
CanGetPortStatus(&port_status);
CanClearOverrun();
34Function Reference
Page 43
CanCloseDriver(handle);
CanGetLedStatus()
PurposeGet the LED status of cPCI-7841 and PM-
7841
PrototypeC/C++
BYTE CanGetLedStatus (int card, int
index);
Parameterscard : card number
Index : index of LED
Return Valuestatus of Led
Value Function
0Led Off
1Led On
RemarksGet the status of Led
This function supports the cPCI-7841 and
PM-7841.
See AlsoCanSetLEDStatus()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
BYTE flag = CanGetLedStatus(0, 0);;
CanCloseDriver(handle);
CanSetLedStatus()
PurposeSet the Led Status of cPCI-7841
PrototypeC/C++
void CanSetLedStatus(int card, int index,
int flashMode);
Parameterscard : card number
Index : index of Led
flashMode :
Value Function
Function Reference 35
Page 44
0Led Off
1Led On
Return Valuenone
RemarksSet Led status of cPCI-7841 and PM-7841
This function supports the cPCI-7841 and
PM-7841
See AlsoCanRcvMsg()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
….
CanSetLedStatus(0, 0, 2);//Set Led to flash
CanCloseDriver(handle);
CanGetRcvCnt()
PurposeGet the how many message in the FIFO
PrototypeC/C++
int _stdcall CanGetRcvCnt(int handle)
Parametershandle : handle retrieve from CanOpen-
Driver()
Return Valuevalue indicates the left unread messages in
the FIFO.
RemarksGet the unread message count in the FIFO.
Because the interrupt would be very busy
while CAN bus is busy. There is possibility
to lost the event in Windows system. A way
to solve to this problem is to call this function at free time while program running. You
also can call this function to make sure that
receiving FIFO is empty.
See AlsoCanGetReceiveEvent()
UsageC/C++
#include “pci7841.h
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
…..
int count = CanGetRcvCnt(handle);.
36Function Reference
Page 45
Error and Event Handling Functions
When the exception occurs, your program may need to take some
algorithm to recover the problem. The following functions are operation-system depended functions. You should care about the
restriction in the operation-system.
DOS Environment
CanInstallCallBack()
PurposeInstall callback function of event under DOS
environment
PrototypeC/C++ (DOS)
void far*CanInstallCallBack(int handle, int
index, void (far* proc)() );
Parametershandle : handle retrieve from CanOpen-
Driver()
Index : event type
IndexType
2Error Warning
3Data Overrun
4Wake Up
5Error Passive
6Arbitration Lost
7Bus Error
void (far *proc)() : Call-back function
The suggested prototype of the call-back
function is like void (far ErrorWarning)();
Return ValuePrevious call back function (NULL when
there is no Call back installed)
RemarksInstall the call-back function for event han-
dling
In normal state, all hardware interrupt of
cPCI/PCI-7841 wouldn’t be set except
receive and transmit interrupt. After calling
the CanInstallCallBack(), the corresponding
interrupt would be activated. The interrupt
Function Reference 37
Page 46
occurs when the event happened. It will not
be disabled until using CanRemoveCallBack() or a hardware reset.
Actually, the call-back function is a part of
ISR. You need to care about the DOS reentrance problem, and returns as soon as
possible to preventing the lost of data.
See AlsoCanRemoveCallBack()
UsageC/C++(DOS)
#include “pci7841.h
void (far ErrorWarning)();
int handle = CanOpenDriver(0, 0);
//open the port 0 of card 0
…
//Installs the ErrorWarning handling event and
RemarksInstall the call-back function for event han-
dling
In normal state, all hardware interrupt of
cPCI/PCI-7841 wouldn’t be set except
receive and transmit interrupt. After calling
the CanInstallCallBack(), the corresponding
interrupt would be activated. The interrupt
occurs when the event happened. It will not
be disabled until using CanRemoveCallBack() or a hardware reset.
Actually, the call-back function is a part of
ISR. You need to care about the DOS reentrance problem, and returns as soon as
possible to preventing the lost of data.
See AlsoCanRemoveCallBack()
UsageC/C++ (DOS)
#include “pci7841.h
void (far ErrorWarning)();
int handle = CanOpenDriver(0, 0);//open the port
0 of card 0
…
//Installs the ErrorWarning handling event and
stores the previous one.
void (far *backup) = CanInstallCallBack(0, 2,
ErrorWarning);
CanRemoveCallBack(0, 2, NULL);//Remove the call-
Heven : HANDLE point for receive event
Return Valuenone
RemarksRetrieve receive notify event
Under Windows 95/98/NT environment,
your program can wait the input message
by waiting an event. You can refer to follow-
ing program to use this function. But the
CAN system is a heavy-load system. Under
the full speed(of course, it depends on your
system), the hardware receives the mes-
sage faster than the event occurs. Under
this condition, the event could be combined
by OS. So the total count of event may be
less than actually receive. You can call the
CanGetRcvCnt() to retrieve the unread
message in the driver’s FIFO.
See AlsoCanGetRcvCnt()
UsageC/C++ (Windows 95/98/NT)
#include “pci7841.h
HANDLE recvEvent0;
int handle = CanOpenDriver(0, 0);
//open the port 0 of card 0
int count1;
CanGetReceiveEvent(handle, rcvEvent0);
if(WaitForSingleObject(rcvEvent0, INFINITE)
== WAIT_OBJECT_0)
{
40Function Reference
Page 49
//You need not to call ResetEvent()…..
err=CanRcvMsg(handle,&rcvMsg[0]
[rcvPatterns[0]]);
rcvPatterns[0]++;
}
cout1 = CanGetRcvCnt(handle[0]);
//To retrieve number of unread
//in the FIFO
CanInstallEvent()
PurposeInstall the event under Windows 95/98/NT
system
PrototypeC/C++ (Windows 95/98/NT)
int CanInstallEvent(int handle, int index,
HANDLE hEvent);
Parametershandle : handle retrieve from CanOpen-
Driver()
Index : event type
IndexType
2Error Warning
3Data Overrun
4Wake Up
5Error Passive
6Arbitration Lost
7Bus Error
HEvent : HANDLE created from CreateEvent()(Win32 SDK)
Return ValueReturn 0 is successful
-1 if error occurs
RemarksInstall the notify event
Unlike the Dos environment, there is only
one error handling function under Windows
95/98/NT environment. First you need to
create an event object, and send it to the
DLL. The DLL would make a registry in the
kernel and pass it to the VxD(SYS in NT
Function Reference 41
Page 50
system). You can’t release the event object
you created, because it was attached to the
VxD. The VxD would release the event
object when you installed another event.
One way to disable the event handling is
that you install another event which handle
is NULL (ex: CanInstallEvent(handle, index,
NULL)). And you can create a thread to
handle the error event.
See AlsoCanRemoveCallBack(),CanInstallCall-
Back()
UsageC/C++ (Windows 95/98/NT)
#include “pci7841.h
int handle = CanOpenDriver(0, 0);
//open the port 0 of card 0
…
//Installs the ErrorWarning handling event and
stores the previous one.
HANDLE hEvent = CreateEvent(NULL, FALSE, TRUE,
“ErrorWarning”);
CanInstallEvent(0, 2, hEvent);
//..create a thread ….
Thank you for choosing ADLINK. To understand your rights and
enjoy all the after-sales services we offer, please read the following carefully.
1. Before using ADLINK’s products please read the user man-
ual and follow the instructions exactly. When sending in
damaged products for repair, please attach an RMA application form which can be downloaded from: http://
rma.adlinktech.com/policy/.
2. All ADLINK products come with a limited two-year war-
ranty, one year for products bought in China:
X The warranty period starts on the day the product is
shipped from ADLINK’s factory.
X Peripherals and third-party products not manufactured
by ADLINK will be covered by the original manufactur-
ers' warranty.
X For products containing storage devices (hard drives,
flash cards, etc.), please back up your data before send-
ing them for repair. ADLINK is not responsible for any
loss of data.
X Please ensure the use of properly licensed software with
our systems. ADLINK does not condone the use of
pirated software and will not service systems using such
software. ADLINK will not be held legally responsible for
products shipped with unlicensed software installed by
the user.
X For general repairs, please do not include peripheral
accessories. If peripherals need to be included, be cer-
tain to specify which items you sent on the RMA Request
& Confirmation Form. ADLINK is not responsible for
items not listed on the RMA Request & Confirmation
Form.
Warranty Policy 43
Page 52
3. Our repair service is not covered by ADLINK's guarantee
in the following situations:
X Damage caused by not following instructions in the
User's Manual.
X Damage caused by carelessness on the user's part dur-
ing product transportation.
X Damage caused by fire, earthquakes, floods, lightening,
pollution, other acts of God, and/or incorrect usage of
voltage transformers.
X Damage caused by unsuitable storage environments
(i.e. high temperatures, high humidity, or volatile chemicals).
X Damage caused by leakage of battery fluid during or
after change of batteries by customer/user.
X Damage from improper repair by unauthorized ADLINK
technicians.
X Products with altered and/or damaged serial numbers
are not entitled to our service.
X This warranty is not transferable or extendible.
X Other categories not protected under our warranty.
4. Customers are responsible for shipping costs to transport
damaged products to our company or sales office.
5. To ensure the speed and quality of product repair, please
download an RMA application form from our company website: http://rma.adlinktech.com/policy. Damaged products
with attached RMA forms receive priority.
If you have any further questions, please email our FAE staff:
service@adlinktech.com.
44Warranty Policy
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.