Class SerialPortController


  • public class SerialPortController
    extends java.lang.Object
    This class provides a set of functions for use with an IMUSensor accessor from within Ptolemy II. This thread keeps an object of type ReaderM that starts a thread and continuously reads from the serial port that the sensor is connected on.
    Since:
    Ptolemy II 11.0
    Version:
    $Id$, $Id$
    Author:
    Hunter Massey and Rajesh Kuni
    See Also:
    ReaderM
    Pt.AcceptedRating:
    Pt.ProposedRating:
    Yellow Hunter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] getSample()
      Grab the latest unread sample from the buffer and return it.
      void start​(int x)
      Starts a serial port connection with comm port with number x (ex: COM8).
      void stop()
      Stops the reading ReaderM thread and terminates the serial connection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SerialPortController

        public SerialPortController()
        Base constructor. No input values
    • Method Detail

      • start

        public void start​(int x)
        Starts a serial port connection with comm port with number x (ex: COM8).
        Parameters:
        x - The serial port number to connect to
      • getSample

        public int[] getSample()
        Grab the latest unread sample from the buffer and return it. Returns latest sample upon call if read index has caught up to write index.
        Returns:
        The latest unread sample, or the latest read sample if write index = read index in buffer
      • stop

        public void stop()
        Stops the reading ReaderM thread and terminates the serial connection.