com.dalsemi.comm
Class CanFrame

java.lang.Object
  |
  +--com.dalsemi.comm.CanFrame

public class CanFrame
extends Object

The CANFrame class is used with the CanBus class to send and receive frames on the CAN Bus.

See Also:
CanBus

Field Summary
 byte[] data
          Frame data area.
 boolean extendedID
          Standard ID (11 bits) if false or Extended ID (29 bits) if true.
 int ID
          Standard ID (11 bits) or Extended ID (29 bits) based on the value of extendedID.
 int length
          Length of data area.
 int messageCenter
          CAN Controller Message Center.
 boolean remoteFrameRequest
          Remote Frame if true or Data Frame if false .
 
Constructor Summary
CanFrame()
          Creates a new CAN Frame with default parameters.
CanFrame(int ID, boolean extendedID, byte[] buf, int length)
          Creates a new CAN Frame with specified parameters.
 
Method Summary
 byte[] getData()
          Gets the data for the incoming or outgoing frame.
 boolean getExtendedID()
          Gets the ID field type on a CAN Frame.
 int getID()
          Gets the ID field on a CAN Frame to be sent or already received.
 int getLength()
          Gets the length of the data in the incoming or outgoing frame.
 int getMessageCenter()
          Gets the message center where this frame was received, or where this frame will be sent.
 boolean getRemoteFrameRequest()
          Gets the RTR bit in the frame to determine if it is a Remote Frame.
 void setData(byte[] buf)
          Sets the data for the outgoing frame.
 void setExtendedID(boolean extendedID)
          Sets the ID field type on a CAN Frame.
 void setID(int ID)
          Sets the ID field on a CAN Frame.
 void setLength(int length)
          Sets the length for the data in the outgoing frame.
 void setMessageCenter(int MC)
          Sets the message center from which to send this CAN Frame.
 void setRemoteFrameRequest(boolean RTR)
          Sets the RTR bit in the frame to change this from a Data Frame to a Remote Frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public int ID
Standard ID (11 bits) or Extended ID (29 bits) based on the value of extendedID.

extendedID

public boolean extendedID
Standard ID (11 bits) if false or Extended ID (29 bits) if true.

messageCenter

public int messageCenter
CAN Controller Message Center.

remoteFrameRequest

public boolean remoteFrameRequest
Remote Frame if true or Data Frame if false .

data

public byte[] data
Frame data area.

length

public int length
Length of data area.
Constructor Detail

CanFrame

public CanFrame()
Creates a new CAN Frame with default parameters. Equivalent of the following code:
 ID = 0;
 extendedID = false;
 messageCenter = 0;
 remoteFrameRequest = false;
 data = new byte[8];
 length = 0;
 

CanFrame

public CanFrame(int ID,
                boolean extendedID,
                byte[] buf,
                int length)
Creates a new CAN Frame with specified parameters.
Parameters:
ID - identifier on frame
extendedID - true for extended ID (29 bit), or false for standard ID (11 bit)
buf - data for frame (maximum 8 bytes)
length - length of data
Method Detail

setID

public void setID(int ID)
Sets the ID field on a CAN Frame.
Parameters:
ID - identifier on frame

getID

public int getID()
Gets the ID field on a CAN Frame to be sent or already received.
Returns:
identifier on frame

setExtendedID

public void setExtendedID(boolean extendedID)
Sets the ID field type on a CAN Frame.
Parameters:
extendedID - true for extended ID (29 bit), or false for standard ID (11 bit)

getExtendedID

public boolean getExtendedID()
Gets the ID field type on a CAN Frame.
Returns:
true for extended ID (29 bit), or false for standard ID (11 bit)

setMessageCenter

public void setMessageCenter(int MC)
Sets the message center from which to send this CAN Frame.
Parameters:
MC - message Center to use

getMessageCenter

public int getMessageCenter()
Gets the message center where this frame was received, or where this frame will be sent.
Returns:
message center

setRemoteFrameRequest

public void setRemoteFrameRequest(boolean RTR)
Sets the RTR bit in the frame to change this from a Data Frame to a Remote Frame.
Parameters:
RTR - true for Remote Frame, false for Data Frame

getRemoteFrameRequest

public boolean getRemoteFrameRequest()
Gets the RTR bit in the frame to determine if it is a Remote Frame.
Returns:
true for Remote Frame, false for Data Frame

setData

public void setData(byte[] buf)
Sets the data for the outgoing frame. Maximum data length is 8 bytes.
Parameters:
buf - data to put in frame

getData

public byte[] getData()
Gets the data for the incoming or outgoing frame.
Returns:
data in frame

setLength

public void setLength(int length)
Sets the length for the data in the outgoing frame. Maximum data length is 8 bytes.
Parameters:
len - length of data in frame

getLength

public int getLength()
Gets the length of the data in the incoming or outgoing frame.
Returns:
length of data in frame