Class SerialTransmitter

java.lang.Object
org.emrick.project.SerialTransmitter

public class SerialTransmitter extends Object
  • Field Details

    • sp

      private com.fazecast.jSerialComm.SerialPort sp
    • type

      private String type
    • inPreviewMode

      private boolean inPreviewMode
  • Constructor Details

    • SerialTransmitter

      public SerialTransmitter()
  • Method Details

    • writeFully

      private static int writeFully(com.fazecast.jSerialComm.SerialPort port, byte[] data)
      Writes every byte, looping in case the driver accepts only part of the buffer in one call.
      Returns:
      number of bytes written, or -1 on failure
    • drainOutput

      private static void drainOutput(com.fazecast.jSerialComm.SerialPort port, int byteCount)
      Blocks until everything written has actually left the PC, so the port can be safely closed. Do not call flushIOBuffers() after a write: on Windows it purges bytes still queued for transmission, which silently cut off the tail of long writes such as a full show upload.
    • getPortNames

      public static com.fazecast.jSerialComm.SerialPort[] getPortNames()
    • setSerialPort

      public boolean setSerialPort(String port)
    • getSerialPort

      public com.fazecast.jSerialComm.SerialPort getSerialPort()
    • getType

      public String getType()
    • setType

      public void setType(String type)
    • writeBoardID

      public void writeBoardID(String boardID, String position)
    • writeLabel

      public boolean writeLabel(String label)
      Stores the board label (e.g. T10L) on a receiver so it can identify itself without a project open. Sent as a runtime command after boot, so receivers on firmware without label support simply ignore it.
      Returns:
      true if the receiver confirmed the label
    • writeLEDCount

      public void writeLEDCount(String ledCount)
    • enterPreviewMode

      public void enterPreviewMode()
      Resets the Receiver into hardware Preview Mode. Idempotent; leaves the port open for subsequent packets.
    • writePreviewPacket

      public void writePreviewPacket(String packetLine)
      Sends one packet line (Packet::fromString format) to be rendered immediately by the Receiver.
    • exitPreviewMode

      public void exitPreviewMode()
      Tells the Receiver to leave Preview Mode and resume normal operation.
    • writeShow

      public void writeShow(String token, String show)
    • getBoardType

      public String getBoardType(String port)
    • writeSet

      public void writeSet(int set)
    • enterProgMode

      public void enterProgMode(String ssid, String password, int port, int id, long token, Color verificationColor)
    • writeToSerialPort

      public void writeToSerialPort(String str)