|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeak.canlight.CANLight
public class CANLight
This is the main class for using the pcanlight api
with your java applications.
Steps to use this api:
1. Create a new CANLight object:
example:
can = new CANLight();
(or use an constructor which returns an initialized object) 2. Call the initializeAPI method passing the hardware parameter which you want use
example to initialize a USB hardware channel 1:
can.initializeAPI(CANLight.PCAN_USB_1CH);
(All hardwares are represented by a static constant prefixed by 'PCAN_') 3. If necessary call setFilter(), resetFilter() or resetClient() example: can.resetClient(); can.resetFilter(); can.setFilter(0x000,0x123,CANLight.TYPE_ST); 4. Call the read or write method
example: CANMessage msg; msg = can.read(); can.write(msg); (do not forget to check if msg is null after calling the read method)
5. At the end call the close method example: can.close();
import peak.canlight.*; public class MinimalisticProgram { public static void main(String[] args) { CANLight can; CANMessage msg; int res; can = new CANLight(); if(!can.initializeAPI(CANLight.PCAN_USB_1CH)) { System.out.println("Unable to initialize the API"); System.exit(0); } res = canLight.init(CANLight.BAUD_1M, CANLight.MAX_EXTENDED_ID); msg = new CANMessage(); while(true) { while(can.read(msg) == CANLight.ERR_OK) { res = can.write(msg); if(res != CANLight.ERR_OK) { System.out.println("Unable to write the CAN message"); System.exit(0); } } } } }
Field Summary | |
---|---|
static int |
BAUD_100K
A constant for 100 Kilobaud |
static int |
BAUD_10K
A constant for 10 Kilobaud |
static int |
BAUD_125K
A constant for 125 Kilobaud |
static int |
BAUD_1M
A constant for 1 Megabaud |
static int |
BAUD_20K
A constant for 20 Kilobaud |
static int |
BAUD_250K
A constant for 250 Kilobaud |
static int |
BAUD_500K
A constant for 500 Kilobaud |
static int |
BAUD_50K
A constant for 50 Kilobaud |
static int |
BAUD_5K
A constant for 5 Kilobaud |
static int |
ERR_ANYBUSERR
A constant for all others error status <> 0 please ask by PEAK ......intern Driver errors..... |
static int |
ERR_BUSHEAVY
A constant for bus error: an Error count reached the limit |
static int |
ERR_BUSLIGHT
A constant for bus error: an Error count reached the limit |
static int |
ERR_BUSOFF
A constant for bus error: CAN_Controller went to 'Bus-Off' |
static int |
ERR_HWINUSE
A constant for ERR_HWINUSE |
static int |
ERR_ILLHW
A constant for invalid Hardware handle |
static int |
ERR_MASK_ILLHANDLE
A constant for mask for all Handle errors |
static int |
ERR_NETINUSE
A constant for ERR_NETINUSE |
static int |
ERR_NO_DLL
A constant for a Dll could not be loaded or a function was not found into the Dll |
static int |
ERR_NOVXD
A constant for problem with Localization of the VxD |
static int |
ERR_OK
A constant for no error |
static int |
ERR_OVERRUN
A constant for a constant for CAN-Controller was read to late |
static int |
ERR_PARMTYP
A constant for parameter not permitted |
static int |
ERR_PARMVAL
A constant for invalid Parameter value |
static int |
ERR_QOVERRUN
A constant for rcvQueue was read to late |
static int |
ERR_QRCVEMPTY
A constant for rcvQueue is empty |
static int |
ERR_QXMTFULL
A constant for send queue is full |
static int |
ERR_REGTEST
A constant for registerTest of the 82C200/SJA1000 failed |
static int |
ERR_RESOURCE
A constant for not generatably Resource (FIFO Client Timeout) |
static int |
ERR_XMTFULL
A constant for send buffer of the Controller ist full |
static int |
HW_DONGLE_PRO
A constant for Dongle Pro hardware |
static int |
HW_DONGLE_SJA
A constant for SJA Dongle hardware |
static int |
HW_ISA
A constant for ISA hardware |
static int |
HW_ISA_SJA
A constant for SJA ISA hardware |
static int |
HW_PCI
A constant for PCI hardware |
static int |
MAX_EXTENDED_ID
Maximal values for the extended ID of a CAN Message |
static int |
MAX_STANDARD_ID
Maximal values for the standard ID of a CAN Message |
static byte |
MSG_TYPE_STATUS
Status Message |
static byte |
MSGTYPE_EXTENDED
29bit message type (extended) |
static byte |
MSGTYPE_RTR
Remote request |
static byte |
MSGTYPE_STANDARD
11bit message type (standard) |
static int |
PCAN_DNG
A constant for DONGLE |
static int |
PCAN_DNP
A constant for DONGLE PRO |
static int |
PCAN_ISA_1CH
A constant for ISA 1st channel |
static int |
PCAN_ISA_2CH
A constant for ISA 2nd channel |
static int |
PCAN_PCC_1CH
A constant for PCC 1st channel |
static int |
PCAN_PCC_2CH
A constant for PCC 2nd channel |
static int |
PCAN_PCI_1CH
A constant for PCI 1st channel |
static int |
PCAN_PCI_2CH
A constant for PCI 2nd channel |
static int |
PCAN_USB_1CH
A constant for USB 1st channel |
static int |
PCAN_USB_2CH
A constant for USB 2nd channel |
static int |
TYPE_EX
A constant for the 29bit message type (extended) |
static int |
TYPE_ST
A constant for the 11bit message type (standard) |
Constructor Summary | |
---|---|
CANLight()
Standard Contructor If an object is created with this constructer use init() to initialize the object |
Method Summary | |
---|---|
int |
close()
Deactivates the hardware and frees all used resources |
int |
getDLLVersionInfo(java.lang.StringBuffer strBuffer)
Returns the version information of the used PCAN-Light DLL |
int |
getStatus()
Returns the status of the hardware |
int |
getUSBDeviceNr(int[] deviceNumber)
Returns the device number of a USB CAN Hardware |
int |
getVersionInfo(java.lang.StringBuffer strBuffer)
Returns a String with version and copyright information |
int |
init(int baudRate,
int msgType)
Activates the PNP hardware, initializes it and makes some tests Use this method only with PNP hardware! |
int |
init(int baudRate,
int msgType,
int ioPort,
int interrupt)
Activates the NON PNP hardware, initializes it and makes some tests. |
boolean |
initializeAPI(int hwType)
Initializes the PCANLight for a specific hardware |
int |
read(CANMessage message)
Reads the next message. |
int |
readEx(CANMessage message,
CANTimestamp rcvTime)
Reads the next message. |
int |
resetClient()
Clears the receive- and transmit-queues. |
int |
resetFilter()
Closes the hardware filter such, that no more messages will be received |
int |
resetRcvEvent()
Resets the handle of the Receive-Event. |
int |
setFilter(int from,
int to,
int msgType)
Sets a hardware or software filter depending on the message type passed as third parameter |
int |
setRcvEvent()
Sets the handle of the Receive-Event. |
int |
setUSBDeviceNr(int deviceNumber)
Write the new device number of a USB CAN Hardware |
int |
write(CANMessage message)
Writes a message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BAUD_1M
public static final int BAUD_500K
public static final int BAUD_250K
public static final int BAUD_125K
public static final int BAUD_100K
public static final int BAUD_50K
public static final int BAUD_20K
public static final int BAUD_10K
public static final int BAUD_5K
public static final int TYPE_ST
public static final int TYPE_EX
public static final byte MSGTYPE_STANDARD
public static final byte MSGTYPE_RTR
public static final byte MSGTYPE_EXTENDED
public static final byte MSG_TYPE_STATUS
public static final int MAX_STANDARD_ID
public static final int MAX_EXTENDED_ID
public static final int HW_ISA
public static final int HW_DONGLE_SJA
public static final int HW_DONGLE_PRO
public static final int HW_ISA_SJA
public static final int HW_PCI
public static final int PCAN_ISA_1CH
public static final int PCAN_ISA_2CH
public static final int PCAN_PCI_1CH
public static final int PCAN_PCI_2CH
public static final int PCAN_PCC_1CH
public static final int PCAN_PCC_2CH
public static final int PCAN_USB_1CH
public static final int PCAN_USB_2CH
public static final int PCAN_DNP
public static final int PCAN_DNG
public static final int ERR_OK
public static final int ERR_XMTFULL
public static final int ERR_OVERRUN
public static final int ERR_BUSLIGHT
public static final int ERR_BUSHEAVY
public static final int ERR_BUSOFF
public static final int ERR_QRCVEMPTY
public static final int ERR_QOVERRUN
public static final int ERR_QXMTFULL
public static final int ERR_REGTEST
public static final int ERR_NOVXD
public static final int ERR_HWINUSE
public static final int ERR_NETINUSE
public static final int ERR_ILLHW
public static final int ERR_RESOURCE
public static final int ERR_PARMTYP
public static final int ERR_PARMVAL
public static final int ERR_MASK_ILLHANDLE
public static final int ERR_ANYBUSERR
public static final int ERR_NO_DLL
Constructor Detail |
---|
public CANLight()
Method Detail |
---|
public boolean initializeAPI(int hwType)
hwType
- the hardware to be usedpublic int init(int baudRate, int msgType)
baudRate
- the baudrate to be usedmsgType
- the type of the message frame (standard or extended)
public int init(int baudRate, int msgType, int ioPort, int interrupt)
baudRate
- the baudrate to be usedmsgType
- the type of the message frame (standard or extended)ioPort
- the io port to useinterrupt
- the interrupt to use
public int getVersionInfo(java.lang.StringBuffer strBuffer)
strBuffer
- String buffer to return the hardware information (max. 255 characters)
public int getDLLVersionInfo(java.lang.StringBuffer strBuffer)
strBuffer
- String buffer to return the DLL information (max. 255 characters)
public int getUSBDeviceNr(int[] deviceNumber)
deviceNumber
- number a single element array to pass an Integer by reference which represents the device number
public int setUSBDeviceNr(int deviceNumber)
deviceNumber
- device number
public int close()
public int getStatus()
public int read(CANMessage message)
message
- An existing message object, that should be "filled" with data should not be null
CANMessage
public int readEx(CANMessage message, CANTimestamp rcvTime)
message
- An existing message object, that should be "filled" with data. Should not be nullrcvTime
- The TPCANTimestamp structure for the message's timestamp
CANMessage
,
CANTimestamp
public int setFilter(int from, int to, int msgType)
from
- The smallest message ID, which should be receivedto
- The largest message ID, which should be receivedmsgType
- The message type (use TYPE_ST or TYPE_EX)
public int resetFilter()
public int write(CANMessage message)
message
- The message that should be written to the can bus
CANMessage
public int resetClient()
public int setRcvEvent()
public int resetRcvEvent()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |