2017-01-10 19:26:44 +01:00
|
|
|
# Serial On Data Received
|
|
|
|
|
|
|
|
Registers an event to be fired when one of the delimiter is matched.
|
|
|
|
|
|
|
|
|
|
|
|
```sig
|
|
|
|
serial.onDataReceived(",", () => {})
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2017-01-10 19:26:44 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* `delimiters` is a [string](/types/string) containing any of the character to match
|
2017-01-10 19:26:44 +01:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Example
|
2017-01-10 19:26:44 +01:00
|
|
|
|
|
|
|
Read values separated by `,`:
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
serial.onDataReceived(serial.delimiters(Delimiters.Comma), () => {
|
|
|
|
basic.showString(serial.readUntil(serial.delimiters(Delimiters.Comma)))
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See also
|
2017-01-10 19:26:44 +01:00
|
|
|
|
|
|
|
[serial](/device/serial),
|
|
|
|
[serial write line](/reference/serial/write-line),
|
|
|
|
[serial write value](/reference/serial/write-value)
|
|
|
|
|