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 CANStreamMessage { 009 /** The message data. */ 010 @SuppressWarnings("MemberName") 011 public final byte[] data = new byte[64]; 012 013 /** The length of the data received (0-64 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 milliseconds (based off of CLOCK_MONOTONIC). */ 022 @SuppressWarnings("MemberName") 023 public long timestamp; 024 025 /** The message ID. */ 026 @SuppressWarnings("MemberName") 027 public int messageId; 028 029 /** Default constructor. */ 030 public CANStreamMessage() {} 031 032 /** 033 * API used from JNI to set the data. 034 * 035 * @param length Length of packet in bytes. 036 * @param messageId CAN message ID of the message. 037 * @param flags Message flags. 038 * @param timestamp CAN frame timestamp in microseconds. 039 * @return Buffer containing CAN frame. 040 */ 041 @SuppressWarnings("PMD.MethodReturnsInternalArray") 042 public byte[] setStreamData(int length, int flags, int messageId, long timestamp) { 043 this.messageId = messageId; 044 this.flags = flags; 045 this.length = length; 046 this.timestamp = timestamp; 047 return data; 048 } 049}