Canconfigport() – ADLINK PCI-7841/cPCI-7841 User Manual

Page 30

Advertising
background image

22

Function Reference

Parameters

handle : handle retrieve from CanOpen-
Driver()
Port : index of port

Return Value

Return 0 if successful
-1 if error occurs

Remarks

Call this function to close a port.

See Also

CanOpenDriver()

Usage

See usage of CanOpenDriver().

CanConfigPort()

Purpose

Configure properties of a port

Prototype

C/C++
int CanConfigPort(int handle,
PORT_STRUCT *ptrStruct)

Parameters

handle : handle retrieve from CanOpen-
Driver()
PtrStruct : a pointer of PORT_STRUCT
type

Return Value

Return 0 is successful
-1 if error occurs

Remarks

Configure 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 Also

PORT_STRUCT structure define

Usage

C/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

MAC_IDs input

port_struct.baudrate = 0;//125K bps
CanConfigPort(handle, &port_struct);

Advertising