C# Класс Serial, UnitySerialPort

Наследование: UnrealBuildTool.ModuleRules
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
EnableDebugInfos bool
NotifyData bool
NotifyLines bool
NotifyValues bool
RememberLines int
SkipFirstLine bool
ValuesSeparator char

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
receivedData ( string data ) : void

Приватные методы

Метод Описание
GetPortName ( ) : string

Описание методов

ClearReceivedBytes() публичный метод

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
Результат void

GetLastLine() публичный метод

public GetLastLine ( bool keepLines = false ) : string
keepLines bool
Результат string

GetLines() публичный метод

public GetLines ( bool keepLines = false ) : List
keepLines bool
Результат List

OnApplicationQuit() публичный метод

public OnApplicationQuit ( ) : void
Результат void

OnDisable() публичный метод

public OnDisable ( ) : void
Результат void

OnEnable() публичный метод

public OnEnable ( ) : void
Результат void

OnGUI() публичный метод

public OnGUI ( ) : void
Результат void

OnValidate() публичный метод

public OnValidate ( ) : void
Результат void

ReadSerialLoop() публичный метод

public ReadSerialLoop ( ) : IEnumerator
Результат IEnumerator

ReadSerialLoopWin() публичный метод

public ReadSerialLoopWin ( ) : IEnumerator
Результат IEnumerator

SimulateDataReceptionLn() публичный метод

Act as if the serial port has received data followed by a new line.
public SimulateDataReceptionLn ( float data ) : void
data float
Результат void

SimulateDataReceptionLn() публичный метод

Act as if the serial port has received data followed by a new line.
public SimulateDataReceptionLn ( string data ) : void
data string
Результат void

Start() публичный метод

public Start ( ) : void
Результат void

Update() публичный метод

public Update ( ) : void
Результат void

Write() публичный статический метод

Send data to the serial port.
public static Write ( string message ) : void
message string
Результат void

WriteLn() публичный статический метод

Send data to the serial port and append a new line character (\n)
public static WriteLn ( string message = "" ) : void
message string
Результат void

checkOpen() публичный статический метод

Verify if the serial port is opened and opens it if necessary
public static checkOpen ( int portSpeed = 9600 ) : bool
portSpeed int Port speed.
Результат bool

receivedData() защищенный метод

protected receivedData ( string data ) : void
data string
Результат void

Описание свойств

EnableDebugInfos публичное свойство

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
Результат bool

NotifyData публичное свойство

Enable notification of data as it arrives Sends OnSerialData(string data) message
public bool NotifyData
Результат bool

NotifyLines публичное свойство

Enable line detection and notification on received data. Message OnSerialLine(string line) is sent for every received line
public bool NotifyLines
Результат bool

NotifyValues публичное свойство

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
Результат bool

RememberLines публичное свойство

Maximum number of lines to remember. Get them with GetLines() or GetLastLine()
public int RememberLines
Результат int

SkipFirstLine публичное свойство

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
Результат bool

ValuesSeparator публичное свойство

The values separator.
public char ValuesSeparator
Результат char