RKS+CAN Interfaces
RKS+CAN Interfaces
You can use only one method at a time. On the following pages, both
interfaces are described.
RKS+CAN
C/C++ Interface Description
using RKS-USB.DLL
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
// frame types
#define FRAME_TYPE_NORMAL 0x1
#define FRAME_TYPE_RTR 0x2
#define FRAME_TYPE_NORMAL_EXT 0x3
#define FRAME_TYPE_RTR_EXT 0x4
#define FRAME_TYPE_ERR 0x5
// DLL exports
// Free USB driver and RKS+CAN hardware. Should be called to release interface/driver.
// Set the timeouts for reading / writing data to the RKS+CAN interface. The software
waits at maximum the
// specified values for read/write operations to complete. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSSetTimeouts(DWORD dwMsTimeoutRead, DWORD
dwMsTimeoutWrite);
// Direct read from hardware USB pipes (low level). Not recommended for application
use if you do not know what you do.
extern "C" __declspec(dllexport) BOOL RKSReadPipe(PUCHAR pucBuffer, DWORD
dwBufferLength, DWORD* pdwLengthTransferred, LPOVERLAPPED pOverlapped);
// Direct write to hardware USB pipes (low level). Not recommended for application use
if you do not know what you do.
extern "C" __declspec(dllexport) BOOL RKSWritePipe(PUCHAR pucBuffer, DWORD
dwBufferLength, DWORD* pdwLengthTransferred, LPOVERLAPPED pOverlapped);
// Read from hardware using the specified timeout value as maximum time to finish the
operation. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSRead(PUCHAR pucBuffer, DWORD dwBufferLength,
DWORD* pdwLengthTransferred);
// Write to hardware using the specified timeout value as maximum time to finish the
operation. Returns TRUE on success.
// Get the version of the of the RKS+CAN hardware. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSGetVersion(PUCHAR pucBuffer, DWORD
dwBufferLength);
// Get the serial number of the RKS+CAN hardware (printed on the cable case). Returns
TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSGetSerial(PUCHAR pucBuffer, DWORD
dwBufferLength);
// Return time since RKS-USB driver initialisation. bReInit can be used to reset the
time to zero.
// Can be used to get relatively exact time information, the time is returned in
seconds.
extern "C" __declspec(dllexport) double RKSGetTimeSinceInit(BOOL bReInit = FALSE);
// Get the error status of the RKS+CAN interface in pbyStatus. Returns TRUE on
success.
extern "C" __declspec(dllexport) BOOL RKSCANGetLastStatus(BYTE* pbyStatus);
// Get the supply voltage of the RKS+CAN hardware. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSCANGetUb(DWORD* pdwVoltage_mV);
// Set CAN hardware filtering of the RKS+CAN hardware. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSCANSetFilter(DWORD dwCode, DWORD dwMask);
// Open CAN bus with the desired bitrate. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSCANOpen(DWORD dwBitrate);
// Get one CAN message from the receive queue, RKSCANOpen(...) must have
// been called before. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSCANRx(can_msg_t* pMsg);
// Add one CAN message to the send queue, RKSCANOpen(...) must have
// been called before. Returns TRUE on success.
extern "C" __declspec(dllexport) BOOL RKSCANTx(can_msg_t* pMsg);
Supported commands:
The command can only be sent when the CAN channel is closed.
Example: S6[CR] to setup the CAN for 500kBit/s
The RKS+CAN hardware does not use a SJA1000 hardware but provides
this interface for compatibility purposes. Example: s0714[CR] for
250kBit/s. For details how to calculate the values, see SJA 1000
datasheet or Google/MSN.
3. Setup CAN bitrate, easy form:
synnnnn[CR] where nnnnn = hexadecimal value of the bitrate.
The command can only be sent when the CAN channel is closed.
Example: sy14585[CR] for 83,333kBit/s.
Bit Represents
1 CAN receive FIFO queue full
2 CAN transmit FIFO queue full
3 Error warning (EI), see SJA 1000 datasheet
4 Data Overrun (DOI), see SJA 1000 datasheet
5 unused
6 Error Passive (EPI), see SJA 1000 datasheet
7 Arbitration Lost (ALI), see SJA 1000 datasheet
8 Bus Error (BEI), see SJA 1000 datasheet
The command can only be sent when the CAN channel is closed.
Example: L1[CR] enables listen only mode, L0[CR] disables it.
http://www.canhack.de
http://www.canhack.de/viewtopic.php?t=137
http://shop.dieselschrauber.org/can-interface-kit-p-313.php