FAST SDK Coding Reference 1.0.3
|
Provides methods to communicate over a serial port. More...
Public Types | |
enum | BaudRates |
The baud rates available for Arduino. More... | |
Public Member Functions | |
bool | Open () |
Opens a serial port connection. | |
void | Send (string data) |
Writes a string to the serial port. | |
void | SendAsLine (string data) |
Writes a string with a new line character to the serial port. | |
Public Attributes | |
BaudRates | baudRate = BaudRates._9600 |
Settings, Inspector, Code The baud rate to use for serial communication. | |
int | comPort = 1 |
Settings, Inspector, Code The COM port to use for serial communication. | |
string | id |
Settings, Inspector, Code Identifies this instance. | |
bool | isLogging = true |
Inspector, Code Set to true if all serial activity should be logged to the Editor Console or Player log. | |
UnityAction< string > | onDataReceivedEvent |
Inspector, Code Calls the function(s) subscribed to this UnityAction when data is received. | |
int | readTimeout = 10 |
Inspector, Code The number of milliseconds before a time-out occurs when a read operation does not finish. | |
int | writeTimeout = 10 |
Inspector, Code The number of milliseconds before a time-out occurs when a write operation does not finish. | |
Properties | |
List< string > | Data [get] |
Gets the list of data recieved since the last read. | |
Private Attributes | |
bool | isOverwrite = false |
Inspector Set to true if incoming the data should overwrite the previous data. Otherwise the data will added to FAST.SerialConnection.Data in the order it is recieved. | |
Provides methods to communicate over a serial port.
Receiving data is threaded for high-performance.
string
messages. enum BaudRates |
The baud rates available for Arduino.
bool Open | ( | ) |
Opens a serial port connection.
A Thread
is started if one doesn't exist.
true
if successful, else false
Open()
and configuring a FAST.SerialConnection yourself, FAST.SerialConnectionLoader and FAST.SerialConnectionSettings should be used to open a serial connection with settings from file during the application load screen. void Send | ( | string | data | ) |
Writes a string
to the serial port.
data | The string data to send. |
void SendAsLine | ( | string | data | ) |
Writes a string
with a new line character to the serial port.
data | The string data to send. |
BaudRates baudRate = BaudRates._9600 |
Settings, Inspector, Code
The baud rate to use for serial communication.
Loaded from FAST.SerialConnectionSettings at runtime.
int comPort = 1 |
Settings, Inspector, Code
The COM port to use for serial communication.
Loaded from FAST.SerialConnectionSettings at runtime.
string id |
Settings, Inspector, Code
Identifies this instance.
Loaded from FAST.SerialConnection at runtime.
bool isLogging = true |
Inspector, Code
Set to true
if all serial activity should be logged to the Editor Console or Player log.
Recieved messages are not logged because the communication may be too frequent.
|
private |
Inspector
Set to true
if incoming the data should overwrite the previous data. Otherwise the data will added to FAST.SerialConnection.Data in the order it is recieved.
UnityAction<string> onDataReceivedEvent |
Inspector, Code
Calls the function(s) subscribed to this UnityAction
when data is received.
int readTimeout = 10 |
Inspector, Code
The number of milliseconds before a time-out occurs when a read operation does not finish.
int writeTimeout = 10 |
Inspector, Code
The number of milliseconds before a time-out occurs when a write operation does not finish.
|
get |
Gets the list of data recieved since the last read.
The list of data is ordered from oldest to newest. If FAST.SerialConnection.isOverwrite is true
, the list only has 1 element.
After reading, the list is cleared from FAST.SerialConnection.