Tanoda
SerialController Class Reference
Inheritance diagram for SerialController:

Public Member Functions

string ReadSerialMessage ()
 
void SendSerialMessage (string message)
 
delegate void TearDownFunction ()
 
void SetTearDownFunction (TearDownFunction userFunction)
 

Public Attributes

string portName = "COM3"
 
int baudRate = 9600
 
GameObject messageListener
 
int reconnectionDelay = 1000
 
int maxUnreadMessages = 1
 

Static Public Attributes

const string SERIAL_DEVICE_CONNECTED = "__Connected__"
 
const string SERIAL_DEVICE_DISCONNECTED = "__Disconnected__"
 

Protected Attributes

Thread thread
 
SerialThreadLines serialThread
 

Detailed Description

This class allows a Unity program to continually check for messages from a serial device.

It creates a Thread that communicates with the serial port and continually polls the messages on the wire. That Thread puts all the messages inside a Queue, and this SerialController class polls that queue by means of invoking SerialThread.GetSerialMessage().

The serial device must send its messages separated by a newline character. Neither the SerialController nor the SerialThread perform any validation on the integrity of the message. It's up to the one that makes sense of the data.

Definition at line 26 of file SerialController.cs.

Member Function Documentation

◆ ReadSerialMessage()

string SerialController.ReadSerialMessage ( )

Definition at line 134 of file SerialController.cs.

◆ SendSerialMessage()

void SerialController.SendSerialMessage ( string  message)

Definition at line 144 of file SerialController.cs.

◆ SetTearDownFunction()

void SerialController.SetTearDownFunction ( TearDownFunction  userFunction)

Definition at line 156 of file SerialController.cs.

◆ TearDownFunction()

delegate void SerialController.TearDownFunction ( )

Member Data Documentation

◆ baudRate

int SerialController.baudRate = 9600

Definition at line 33 of file SerialController.cs.

◆ maxUnreadMessages

int SerialController.maxUnreadMessages = 1

Definition at line 45 of file SerialController.cs.

◆ messageListener

GameObject SerialController.messageListener

Definition at line 37 of file SerialController.cs.

◆ portName

string SerialController.portName = "COM3"

Definition at line 30 of file SerialController.cs.

◆ reconnectionDelay

int SerialController.reconnectionDelay = 1000

Definition at line 41 of file SerialController.cs.

◆ SERIAL_DEVICE_CONNECTED

const string SerialController.SERIAL_DEVICE_CONNECTED = "__Connected__"
static

Definition at line 52 of file SerialController.cs.

◆ SERIAL_DEVICE_DISCONNECTED

const string SerialController.SERIAL_DEVICE_DISCONNECTED = "__Disconnected__"
static

Definition at line 53 of file SerialController.cs.

◆ serialThread

SerialThreadLines SerialController.serialThread
protected

Definition at line 57 of file SerialController.cs.

◆ thread

Thread SerialController.thread
protected

Definition at line 56 of file SerialController.cs.


The documentation for this class was generated from the following file: