001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package org.wpilib.hardware.hal.can; 006 007/** Represents a CAN message read from a stream. */ 008public class CANReceiveMessage { 009 /** The message data. */ 010 public final byte[] data = new byte[64]; 011 012 /** The length of the data received (0-8 bytes). */ 013 public int length; 014 015 /** The flags of the message. */ 016 public int flags; 017 018 /** Timestamp message was received, in microseconds (wpi time). */ 019 public long timestamp; 020 021 /** Default constructor. */ 022 public CANReceiveMessage() {} 023 024 /** 025 * API used from JNI to set the data. 026 * 027 * @param length Length of packet in bytes. 028 * @param flags Message flags. 029 * @param timestamp CAN frame timestamp in microseconds. 030 * @return Buffer containing CAN frame. 031 */ 032 @SuppressWarnings("PMD.MethodReturnsInternalArray") 033 public byte[] setReceiveData(int length, int flags, long timestamp) { 034 this.flags = flags; 035 this.length = length; 036 this.timestamp = timestamp; 037 return data; 038 } 039}