pxt-calliope/docs/reference/serial.md

37 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2016-04-16 01:36:31 +02:00
# Serial
Read and write data over a serial connection.
2016-04-16 01:36:31 +02:00
```cards
serial.writeLine("");
2016-05-19 22:56:24 +02:00
serial.writeNumber(0);
2016-08-10 11:51:55 +02:00
serial.writeValue("x", 0);
2016-05-19 22:56:24 +02:00
serial.writeString("");
serial.writeNumbers([0]);
serial.readUntil(",");
2016-05-19 22:56:24 +02:00
serial.readLine();
serial.readString();
serial.onDataReceived(",", () => {})
2016-04-16 01:36:31 +02:00
```
2016-08-08 22:08:15 +02:00
## Advanced
```cards
serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
serial.redirectToUSB();
serial.writeBuffer(serial.readBuffer(64));
serial.readBuffer(64);
serial.setRxBufferSize(64);
serial.setTxBufferSize(64);
```
## See Also
2016-08-08 22:08:15 +02:00
[writeLine](/reference/serial/write-line), [writeNumber](/reference/serial/write-number), [writeValue](/reference/serial/write-value),
[writeString](/reference/serial/write-string),
[writeNumbers](/reference/serial/write-numbers), [readUntil](/reference/serial/read-until), [readLine](/reference/serial/read-line),
[readString](/reference/serial/read-string), [onDataReceived](/reference/serial/on-data-received),
[redirect](/reference/serial/redirect), [writeBuffer](/reference/serial/write-buffer), [readBuffer](/reference/serial/read-buffer),
[redirectToUSB](/reference/serial/redirect-to-usb),
[set rx buffer size](/reference/serial/set-rx-buffer-size),
[set tx buffer size](/reference/serial/set-tx-buffer-size)