User`s manual

Software Manual • EKF Intelligent I/O Controller Family On
CompactPCI
- 23 -
EKF Elektronik GmbH * Philipp-Reis-Str. 4 * D-59065 HAMM (Germany)
Tel. +49 (0)2381/6890-0 * Fax. +49 (0)2381/6890-90 * E-Mail info@ekf.de * Internet http://www.ekf.de
Call: Ekf960SendCanFrame(
handle, // handle returned by
CreateFile
pOverlapped, // optional pointer to overlapped buffer (may be NULL)
SendID, // transmit identifier
CAN_FLAG_EXTENDED,
// send an extended (29 bit ID) frame
bytesToWrite, // number of data bytes to write
pBytesWritten, // pointer to number of data bytes written
pData, // pointer to data buffer
pStatusRecord // optional pointer to status record (may be NULL)
);
The write operation can be timed-out by setting up a timer with the I/O control request
IOCTL_SERIAL_SET_TIMEOUTS.
Read Data
Data reception via a previously successfully opened port is provided by the C function
Read
File
. The data received by the port is written unchanged to the buffer passed to the
function if the following is true:
no XON/XOFF flow control is used,
null stripping mode is turned off,
the error and break character insertion is turned off,
insertion mode is turned off.
Call: ReadFile(
handle, // handle returned by
CreateFile
pBuffer, // pointer to data buffer
bytesToRead, // number of bytes to read
pBytesRead, // pointer to number of bytes read
pOverlapped // pointer to overlapped buffer
);
ReadFile
returns TRUE on success. If the read operation failed, FALSE is returned and a
call to
GetLastError
returns a corresponding error code.
If the port was opened with FILE_FLAG_OVERLAPPED for asynchronous I/O
ReadFile
returns FALSE and
GetLastError
may return ERROR_IO_PENDING. In that case a
subsequent call to
GetOverlappedResult
is necessary. See also the Windows “Visual C++”
documentation for details of asynchronous I/O operations.
On CANbus ports a complete frame including frame information field, received frame
identifier and frame data is returned by
ReadFile
. Therefore it is better to use the C function
Ekf960ReceiveCanFrame
within the static library “ekf960si1.lib” to receive frames via a
CANbus port. This routine calls
ReadFile
and, if necessary,
GetOverlappedResult
and splits
the parts of the received frame. See also the source file of
Ekf960ReceiveCanFrame
“receivecan.c” that is delivered with the driver installation package.