当前位置: 首页>>代码示例>>Java>>正文


Java SerialPort类代码示例

本文整理汇总了Java中edu.wpi.first.wpilibj.SerialPort的典型用法代码示例。如果您正苦于以下问题:Java SerialPort类的具体用法?Java SerialPort怎么用?Java SerialPort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SerialPort类属于edu.wpi.first.wpilibj包,在下文中一共展示了SerialPort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: NavX

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
public NavX() {
	try {
	/***********************************************************************
	 * navX-MXP: 
	 * - Communication via RoboRIO MXP (SPI, I2C, TTL UART) and USB.            
	 * - See http://navx-mxp.kauailabs.com/guidance/selecting-an-interface.
	 * 
	 * navX-Micro:
	 * - Communication via I2C (RoboRIO MXP or Onboard) and USB.
	 * - See http://navx-micro.kauailabs.com/guidance/selecting-an-interface.
	 * 
	 * Multiple navX-model devices on a single robot are supported.
	 ************************************************************************/

		ahrs = new AHRS(SerialPort.Port.kUSB);
	} catch (RuntimeException ex ) {
		DriverStation.reportError("Error instantiating navX MXP:  " + ex.getMessage(), true);
	}

}
 
开发者ID:FRC2832,项目名称:Robot_2017,代码行数:21,代码来源:NavX.java

示例2: IMU

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
/**
 * Constructs the IMU class, overriding the default update rate
 * with a custom rate which may be from 4 to 100, representing
 * the number of updates per second sent by the nav6 IMU.  
 *
 * Note that increasing the update rate may increase the
 * CPU utilization.
 * @param serial_port BufferingSerialPort object to use
 * @param update_rate_hz Custom Update Rate (Hz)
 */
public IMU(SerialPort serial_port, byte update_rate_hz) {
    ypr_update_data = new IMUProtocol.YPRUpdate();
    this.update_rate_hz = update_rate_hz;
    flags = 0;
    accel_fsr_g = DEFAULT_ACCEL_FSR_G;
    gyro_fsr_dps = DEFAULT_GYRO_FSR_DPS;
    this.serial_port = serial_port;
    yaw_history = new float[YAW_HISTORY_LENGTH];
    yaw = (float) 0.0;
    pitch = (float) 0.0;
    roll = (float) 0.0;
    try {
        serial_port.reset();
    } catch (RuntimeException ex) {
        ex.printStackTrace();
    }
    initIMU();
    m_thread = new Thread(this);
    m_thread.start();        
}
 
开发者ID:FRC2832,项目名称:Robot_2016,代码行数:31,代码来源:IMU.java

示例3: IMU

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
public IMU(SerialPort serial_port, byte update_rate_hz) {
	ypr_update_data = new IMUProtocol.YPRUpdate();
	this.update_rate_hz = update_rate_hz;
	flags = 0;
	accel_fsr_g = DEFAULT_ACCEL_FSR_G;
	gyro_fsr_dps = DEFAULT_GYRO_FSR_DPS;
	this.serial_port = serial_port;
	yaw_history = new float[YAW_HISTORY_LENGTH];
	yaw = (float) 0.0;
	pitch = (float) 0.0;
	roll = (float) 0.0;
	try {
		serial_port.reset();
	} catch (RuntimeException e) {
	}
	initIMU();
	m_thread = new Thread(this);
	m_thread.start();
}
 
开发者ID:Prospect-Robotics,项目名称:2016Robot,代码行数:20,代码来源:IMU.java

示例4: SerialIO

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
public SerialIO( SerialPort.Port port_id, byte update_rate_hz, boolean processed_data, IIOCompleteNotification notify_sink, IBoardCapabilities board_capabilities ) {
    this.serial_port_id = port_id;
    ypr_update_data = new IMUProtocol.YPRUpdate();
    gyro_update_data = new IMUProtocol.GyroUpdate();
    ahrs_update_data = new AHRSProtocol.AHRSUpdate();
    ahrspos_update_data = new AHRSProtocol.AHRSPosUpdate();
    board_id = new AHRSProtocol.BoardID();
    board_state = new IIOCompleteNotification.BoardState();
    this.notify_sink = notify_sink;
    this.board_capabilities = board_capabilities;
    serial_port = getMaybeCreateSerialPort();
    this.update_rate_hz = update_rate_hz;
    if ( processed_data ) {
        update_type = AHRSProtocol.MSGID_AHRSPOS_UPDATE;
    } else {
        update_type = IMUProtocol.MSGID_GYRO_UPDATE;
    }
}
 
开发者ID:nerdherd,项目名称:Stronghold2016,代码行数:19,代码来源:SerialIO.java

示例5: AHRS

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
/**
 * Constructs the AHRS class, overriding the default update rate
 * with a custom rate which may be from 4 to 60, representing
 * the number of updates per second sent by the navX MXP.  
 * 
 * Note that increasing the update rate may increase the 
 * CPU utilization.
 * @param serial_port SerialPort object to use
 * @param update_rate_hz Custom Update Rate (Hz)
 */
public AHRS(SerialPort serial_port, byte update_rate_hz) {
    super(serial_port,update_rate_hz);
    ahrs_update_data = new AHRSProtocol.AHRSUpdate();
    update_type = AHRSProtocol.MSGID_AHRS_UPDATE;
    world_linear_accel_x =
    		world_linear_accel_y =
    		world_linear_accel_z =
    		mpu_temp_c =
    		fused_heading =
    		altitude =
    		barometric_pressure =
    		baro_sensor_temp_c =
    		mag_field_norm_ratio = 0.0f;
    cal_mag_x = 
    		cal_mag_y =
    		cal_mag_z = 0;
    is_moving =
    		is_rotating =
    		altitude_valid =
    		is_magnetometer_calibrated =
    		magnetic_disturbance = false;
    resetDisplacement();
}
 
开发者ID:FRC5442,项目名称:Bernie,代码行数:34,代码来源:AHRS.java

示例6: IMU

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
/**
 * Constructs the IMU class, overriding the default update rate
 * with a custom rate which may be from 4 to 100, representing
 * the number of updates per second sent by the nav6 IMU.  
 * 
 * Note that increasing the update rate may increase the 
 * CPU utilization.
 * @param serial_port BufferingSerialPort object to use
 * @param update_rate_hz Custom Update Rate (Hz)
 */
public IMU(SerialPort serial_port, byte update_rate_hz) {
    ypr_update_data = new IMUProtocol.YPRUpdate();
    this.update_rate_hz = update_rate_hz;
    flags = 0;
    accel_fsr_g = DEFAULT_ACCEL_FSR_G;
    gyro_fsr_dps = DEFAULT_GYRO_FSR_DPS;
    this.serial_port = serial_port;
    yaw_history = new float[YAW_HISTORY_LENGTH];
    yaw = (float) 0.0;
    pitch = (float) 0.0;
    roll = (float) 0.0;
    try {
        serial_port.reset();
    } catch (RuntimeException ex) {
        ex.printStackTrace();
    }
    initIMU();
    m_thread = new Thread(this);
    m_thread.start();        
}
 
开发者ID:FRC5442,项目名称:Bernie,代码行数:31,代码来源:IMU.java

示例7: SerialIO

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
public SerialIO( SerialPort.Port port_id, byte update_rate_hz, boolean processed_data, IIOCompleteNotification notify_sink, IBoardCapabilities board_capabilities ) {
    this.serial_port_id = port_id;
    is_usb = ((port_id == SerialPort.Port.kUSB) ||
    		  (port_id == SerialPort.Port.kUSB1)||
    		  (port_id == SerialPort.Port.kUSB2));
    ypr_update_data = new IMUProtocol.YPRUpdate();
    gyro_update_data = new IMUProtocol.GyroUpdate();
    ahrs_update_data = new AHRSProtocol.AHRSUpdate();
    ahrspos_update_data = new AHRSProtocol.AHRSPosUpdate();
    ahrspos_ts_update_data = new AHRSProtocol.AHRSPosTSUpdate();
    board_id = new AHRSProtocol.BoardID();
    board_state = new IIOCompleteNotification.BoardState();
    this.notify_sink = notify_sink;
    this.board_capabilities = board_capabilities;
    serial_port = getMaybeCreateSerialPort();
    this.update_rate_hz = update_rate_hz;
    if ( processed_data ) {
        update_type = AHRSProtocol.MSGID_AHRSPOS_TS_UPDATE;
    } else {
        update_type = IMUProtocol.MSGID_GYRO_UPDATE;
    }
}
 
开发者ID:FRC1458,项目名称:turtleshell,代码行数:23,代码来源:SerialIO.java

示例8: Lights

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
/**
 * Creates a new Lights subsystem.
 */
public Lights() {
  teensyCommunication = new SerialPort(9600, SerialPort.Port.kMXP);
  teensyCommunication.enableTermination();
  
  Thread serialThread = new Thread(this::serialThread);
  serialThread.setName("LED UART Thread");
  serialThread.setDaemon(true);
  serialThread.start();
  
  setLedLight(Type.SIGN_FUEL, Pulse.SOLID, Color.OFF);
  setLedLight(Type.SIGN_GEAR, Pulse.SOLID, Color.OFF);
}
 
开发者ID:ligerbots,项目名称:Steamworks2017Robot,代码行数:16,代码来源:Lights.java

示例9: Vision

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
public Vision(){
	serial = new SerialPort(115200, SerialPort.Port.kMXP, 8, SerialPort.Parity.kNone, SerialPort.StopBits.kOne);
   	serial.disableTermination();
    serial.setTimeout(1);
    serial.setFlowControl(SerialPort.FlowControl.kNone);
	serial.setReadBufferSize(32);
	serial.setWriteBufferSize(8);
	serial.setWriteBufferMode(SerialPort.WriteBufferMode.kFlushOnAccess);
}
 
开发者ID:Team395,项目名称:El-Jefe-2017,代码行数:10,代码来源:Vision.java

示例10: resetSerialPort

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
protected SerialPort resetSerialPort()
{
    if (serial_port != null) {
        try {
            serial_port.free();
        } catch (Exception ex) {
            // This has been seen to happen before....
        }
        serial_port = null;
    }
    serial_port = getMaybeCreateSerialPort();
    return serial_port;
}
 
开发者ID:nerdherd,项目名称:Stronghold2016,代码行数:14,代码来源:SerialIO.java

示例11: ArduPilotAthenaInputStream

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
public ArduPilotAthenaInputStream() {
	try {
		sp = new SerialPort(115200, Port.kUSB);
	} catch (Exception e) {
		;
	}
}
 
开发者ID:first95,项目名称:FRC2016,代码行数:8,代码来源:ArduPilotAthenaInputStream.java

示例12: PixyVision

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
public PixyVision(
    final String instanceName, Robot robot, int signature, int brightness, Orientation orientation,
    SerialPort.Port port)
{
    pixyCamera = new FrcPixyCam(instanceName, port,
        RobotInfo.PIXY_BAUD_RATE, RobotInfo.PIXY_DATA_BITS, RobotInfo.PIXY_PARITY, RobotInfo.PIXY_STOP_BITS);
    commonInit(robot, signature, brightness, orientation);
}
 
开发者ID:trc492,项目名称:Frc2017FirstSteamWorks,代码行数:9,代码来源:PixyVision.java

示例13: FrcSerialPortDevice

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
/**
 * Constructor: Creates an instance of the object.
 *
 * @param instanceName specifies the instance name.
 * @param port specifies the serial port (on-board or on the MXP).
 * @param baudRate specifies the serial baud rate.
 * @param dataBits specifies the number of data bits.
 * @param parity specifies the parity type.
 * @param stopBits specifies the number of stop bits.
 */
public FrcSerialPortDevice(
    final String instanceName, Port port, int baudRate, int dataBits, Parity parity, StopBits stopBits)
{
    super(instanceName);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    device = new SerialPort(baudRate, port, dataBits, parity, stopBits);
}
 
开发者ID:trc492,项目名称:Frc2017FirstSteamWorks,代码行数:23,代码来源:FrcSerialPortDevice.java

示例14: FrcPixyCam

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
/**
 * Constructor: Create an instance of the object.
 *
 * @param instanceName specifies the instance name.
 * @param port specifies the serial port on the RoboRIO.
 * @param baudRate specifies the baud rate.
 * @param dataBits specifies the number of data bits.
 * @param parity specifies the parity type.
 * @param stopBits specifies the number of stop bits.
 */
public FrcPixyCam(
    final String instanceName, SerialPort.Port port, int baudRate, int dataBits, SerialPort.Parity parity,
    SerialPort.StopBits stopBits)
{
    super(instanceName);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    pixyCam = new FrcSerialPortDevice(instanceName, port, baudRate, dataBits, parity, stopBits);
    start();
}
 
开发者ID:trc492,项目名称:Frc2017FirstSteamWorks,代码行数:25,代码来源:FrcPixyCam.java

示例15: FrcEmic2TextToSpeech

import edu.wpi.first.wpilibj.SerialPort; //导入依赖的package包/类
/**
 * Constructor: Create an instance of the object.
 *
 * @param instanceName specifies the instance name.
 * @param port specifies the serial port on the RoboRIO.
 * @param baudRate specifies the baud rate.
 * @param dataBits specifies the number of data bits.
 * @param parity specifies the parity type.
 * @param stopBits specifies the number of stop bits.
 */
public FrcEmic2TextToSpeech(
    final String instanceName, SerialPort.Port port, int baudRate, int dataBits, SerialPort.Parity parity,
    SerialPort.StopBits stopBits)
{
    super(instanceName);

    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    tts = new FrcSerialPortDevice(instanceName, port, baudRate, dataBits, parity, stopBits);
}
 
开发者ID:trc492,项目名称:Frc2017FirstSteamWorks,代码行数:24,代码来源:FrcEmic2TextToSpeech.java


注:本文中的edu.wpi.first.wpilibj.SerialPort类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。