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 edu.wpi.first.hal.can; 006 007/** Represents a CAN message read from a stream. */ 008public class CANReceiveMessage { 009 /** The message data. */ 010 @SuppressWarnings("MemberName") 011 public final byte[] data = new byte[64]; 012 013 /** The length of the data received (0-8 bytes). */ 014 @SuppressWarnings("MemberName") 015 public int length; 016 017 /** The flags of the message. */ 018 @SuppressWarnings("MemberName") 019 public int flags; 020 021 /** Timestamp message was received, in microseconds (wpi time). */ 022 @SuppressWarnings("MemberName") 023 public long timestamp; 024 025 /** Default constructor. */ 026 public CANReceiveMessage() {} 027 028 /** 029 * API used from JNI to set the data. 030 * 031 * @param length Length of packet in bytes. 032 * @param flags Message flags. 033 * @param timestamp CAN frame timestamp in microseconds. 034 * @return Buffer containing CAN frame. 035 */ 036 @SuppressWarnings("PMD.MethodReturnsInternalArray") 037 public byte[] setReceiveData(int length, int flags, long timestamp) { 038 this.flags = flags; 039 this.length = length; 040 this.timestamp = timestamp; 041 return data; 042 } 043}