C# Class Serial, UnitySerialPort

Inheritance: UnrealBuildTool.ModuleRules
Exibir arquivo Open project: prossel/UnitySerialPort Class Usage Examples

Public Properties

Property Type Description
EnableDebugInfos bool
NotifyData bool
NotifyLines bool
NotifyValues bool
RememberLines int
SkipFirstLine bool
ValuesSeparator char

Public Methods

Method Description
ClearReceivedBytes ( ) : void

Clears the received bytes. Warning: This prevents line detection and notification. To be used when no \n is expected to avoid keeping unnecessary big amount of data in memory You should normally not call this function if \n are expected.

GetLastLine ( bool keepLines = false ) : string
GetLines ( bool keepLines = false ) : List
OnApplicationQuit ( ) : void
OnDisable ( ) : void
OnEnable ( ) : void
OnGUI ( ) : void
OnValidate ( ) : void
ReadSerialLoop ( ) : IEnumerator
ReadSerialLoopWin ( ) : IEnumerator
SimulateDataReceptionLn ( float data ) : void

Act as if the serial port has received data followed by a new line.

SimulateDataReceptionLn ( string data ) : void

Act as if the serial port has received data followed by a new line.

Start ( ) : void
Update ( ) : void
Write ( string message ) : void

Send data to the serial port.

WriteLn ( string message = "" ) : void

Send data to the serial port and append a new line character (\n)

checkOpen ( int portSpeed = 9600 ) : bool

Verify if the serial port is opened and opens it if necessary

Protected Methods

Method Description
receivedData ( string data ) : void

Private Methods

Method Description
GetPortName ( ) : string

Method Details

ClearReceivedBytes() public method

Clears the received bytes. Warning: This prevents line detection and notification. To be used when no \n is expected to avoid keeping unnecessary big amount of data in memory You should normally not call this function if \n are expected.
public ClearReceivedBytes ( ) : void
return void

GetLastLine() public method

public GetLastLine ( bool keepLines = false ) : string
keepLines bool
return string

GetLines() public method

public GetLines ( bool keepLines = false ) : List
keepLines bool
return List

OnApplicationQuit() public method

public OnApplicationQuit ( ) : void
return void

OnDisable() public method

public OnDisable ( ) : void
return void

OnEnable() public method

public OnEnable ( ) : void
return void

OnGUI() public method

public OnGUI ( ) : void
return void

OnValidate() public method

public OnValidate ( ) : void
return void

ReadSerialLoop() public method

public ReadSerialLoop ( ) : IEnumerator
return IEnumerator

ReadSerialLoopWin() public method

public ReadSerialLoopWin ( ) : IEnumerator
return IEnumerator

SimulateDataReceptionLn() public method

Act as if the serial port has received data followed by a new line.
public SimulateDataReceptionLn ( float data ) : void
data float
return void

SimulateDataReceptionLn() public method

Act as if the serial port has received data followed by a new line.
public SimulateDataReceptionLn ( string data ) : void
data string
return void

Start() public method

public Start ( ) : void
return void

Update() public method

public Update ( ) : void
return void

Write() public static method

Send data to the serial port.
public static Write ( string message ) : void
message string
return void

WriteLn() public static method

Send data to the serial port and append a new line character (\n)
public static WriteLn ( string message = "" ) : void
message string
return void

checkOpen() public static method

Verify if the serial port is opened and opens it if necessary
public static checkOpen ( int portSpeed = 9600 ) : bool
portSpeed int Port speed.
return bool

receivedData() protected method

protected receivedData ( string data ) : void
data string
return void

Property Details

EnableDebugInfos public_oe property

The enable debug infos. The first script with debug infos enabled will enable them until the program stop. Therefore, only one script need to enable the debug info to have them in all app, even with multiple scene and multiple instances, until the program stops.
public bool EnableDebugInfos
return bool

NotifyData public_oe property

Enable notification of data as it arrives Sends OnSerialData(string data) message
public bool NotifyData
return bool

NotifyLines public_oe property

Enable line detection and notification on received data. Message OnSerialLine(string line) is sent for every received line
public bool NotifyLines
return bool

NotifyValues public_oe property

Enable lines detection, values separation and notification. Each line is split with the value separator (TAB by default) Sends Message OnSerialValues(string [] values)
public bool NotifyValues
return bool

RememberLines public_oe property

Maximum number of lines to remember. Get them with GetLines() or GetLastLine()
public int RememberLines
return int

SkipFirstLine public_oe property

Discard all received data until first line. Do not enable if you do not expect a \n as this would prevent the notification of any line or value. Data notification is not impacted by this parameter.
public bool SkipFirstLine
return bool

ValuesSeparator public_oe property

The values separator.
public char ValuesSeparator
return char