Adding serial.set(Rx|Tx)BufferSize (#1931)
* Fix for https://github.com/Microsoft/pxt-microbit/issues/1929 * bump pxt * updated docs * fix default values * moving dialogs to react * moving to react * typo * typo
This commit is contained in:
parent
d640dc5eed
commit
ea2361792f
@ -21,6 +21,8 @@ serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
|
|||||||
serial.redirectToUSB();
|
serial.redirectToUSB();
|
||||||
serial.writeBuffer(pins.createBuffer(0));
|
serial.writeBuffer(pins.createBuffer(0));
|
||||||
serial.readBuffer(64);
|
serial.readBuffer(64);
|
||||||
|
serial.setRxBufferSize(64);
|
||||||
|
serial.setTxBufferSize(64);
|
||||||
```
|
```
|
||||||
|
|
||||||
## See Also
|
## See Also
|
||||||
@ -30,4 +32,6 @@ serial.readBuffer(64);
|
|||||||
[writeNumbers](/reference/serial/write-numbers), [readUntil](/reference/serial/read-until), [readLine](/reference/serial/read-line),
|
[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),
|
[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),
|
[redirect](/reference/serial/redirect), [writeBuffer](/reference/serial/write-buffer), [readBuffer](/reference/serial/read-buffer),
|
||||||
[redirectToUSB](/reference/serial/redirect-to-usb)
|
[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)
|
23
docs/reference/serial/set-rx-buffer-size.md
Normal file
23
docs/reference/serial/set-rx-buffer-size.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# set Rx Buffer Size
|
||||||
|
|
||||||
|
Sets the length of the serial reception buffer in bytes.
|
||||||
|
|
||||||
|
```sig
|
||||||
|
serial.setRxBufferSize(10)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
* **size**: desired length of the reception buffer
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Allocates 64 bytes for the reception buffer.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
serial.setRxBufferSize(64)
|
||||||
|
```
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
[set tx buffer size](/reference/serial/set-tx-buffer-size)
|
23
docs/reference/serial/set-tx-buffer-size.md
Normal file
23
docs/reference/serial/set-tx-buffer-size.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# set Tx Buffer Size
|
||||||
|
|
||||||
|
Sets the length of the serial transmission buffer in bytes.
|
||||||
|
|
||||||
|
```sig
|
||||||
|
serial.setTxBufferSize(10)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
* **size**: desired length of the transmission buffer
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Allocates 64 bytes for the transmission buffer.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
serial.setTxBufferSize(64)
|
||||||
|
```
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
[set rx buffer size](/reference/serial/set-rx-buffer-size)
|
1057
editor/extension.ts
1057
editor/extension.ts
File diff suppressed because it is too large
Load Diff
1057
editor/extension.tsx
Normal file
1057
editor/extension.tsx
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,11 +3,16 @@
|
|||||||
"target": "es5",
|
"target": "es5",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
|
"noImplicitThis": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"out": "../built/editor.js",
|
"module": "commonjs",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"isolatedModules": false,
|
||||||
|
"outDir": "../built/editor",
|
||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"newLine": "LF",
|
"newLine": "LF",
|
||||||
"sourceMap": false
|
"sourceMap": false,
|
||||||
|
"jsx": "react"
|
||||||
},
|
},
|
||||||
"prepend": ["../external/dapjs.js"]
|
"prepend": ["../external/dapjs.js"]
|
||||||
}
|
}
|
||||||
|
@ -535,6 +535,10 @@
|
|||||||
"serial.redirect|param|rate": "the new baud rate. eg: 115200",
|
"serial.redirect|param|rate": "the new baud rate. eg: 115200",
|
||||||
"serial.redirect|param|rx": "the new reception pin, eg: SerialPin.P1",
|
"serial.redirect|param|rx": "the new reception pin, eg: SerialPin.P1",
|
||||||
"serial.redirect|param|tx": "the new transmission pin, eg: SerialPin.P0",
|
"serial.redirect|param|tx": "the new transmission pin, eg: SerialPin.P0",
|
||||||
|
"serial.setRxBufferSize": "Sets the size of the RX buffer in bytes",
|
||||||
|
"serial.setRxBufferSize|param|size": "length of the rx buffer in bytes, eg: 32",
|
||||||
|
"serial.setTxBufferSize": "Sets the size of the TX buffer in bytes",
|
||||||
|
"serial.setTxBufferSize|param|size": "length of the tx buffer in bytes, eg: 32",
|
||||||
"serial.writeBuffer": "Send a buffer through serial connection",
|
"serial.writeBuffer": "Send a buffer through serial connection",
|
||||||
"serial.writeLine": "Print a line of text to the serial port",
|
"serial.writeLine": "Print a line of text to the serial port",
|
||||||
"serial.writeNumber": "Print a numeric value to the serial port",
|
"serial.writeNumber": "Print a numeric value to the serial port",
|
||||||
|
@ -191,4 +191,23 @@ namespace serial {
|
|||||||
uBit.serial.redirect(USBTX, USBRX);
|
uBit.serial.redirect(USBTX, USBRX);
|
||||||
uBit.serial.baud(115200);
|
uBit.serial.baud(115200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the size of the RX buffer in bytes
|
||||||
|
* @param size length of the rx buffer in bytes, eg: 32
|
||||||
|
*/
|
||||||
|
//% help=serial/set-rx-buffer-size
|
||||||
|
void setRxBufferSize(uint8_t size) {
|
||||||
|
uBit.serial.setRxBufferSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the size of the TX buffer in bytes
|
||||||
|
* @param size length of the tx buffer in bytes, eg: 32
|
||||||
|
*/
|
||||||
|
//% help=serial/set-tx-buffer-size
|
||||||
|
void setTxBufferSize(uint8_t size) {
|
||||||
|
uBit.serial.setTxBufferSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
14
libs/core/shims.d.ts
vendored
14
libs/core/shims.d.ts
vendored
@ -864,6 +864,20 @@ declare namespace serial {
|
|||||||
//% weight=9 help=serial/redirect-to-usb
|
//% weight=9 help=serial/redirect-to-usb
|
||||||
//% blockId=serial_redirect_to_usb block="serial|redirect to USB" shim=serial::redirectToUSB
|
//% blockId=serial_redirect_to_usb block="serial|redirect to USB" shim=serial::redirectToUSB
|
||||||
function redirectToUSB(): void;
|
function redirectToUSB(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the size of the RX buffer in bytes
|
||||||
|
* @param size length of the rx buffer in bytes, eg: 32
|
||||||
|
*/
|
||||||
|
//% help=serial/set-rx-buffer-size shim=serial::setRxBufferSize
|
||||||
|
function setRxBufferSize(size: uint8): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the size of the TX buffer in bytes
|
||||||
|
* @param size length of the tx buffer in bytes, eg: 32
|
||||||
|
*/
|
||||||
|
//% help=serial/set-tx-buffer-size shim=serial::setTxBufferSize
|
||||||
|
function setTxBufferSize(size: uint8): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
4269
package-lock.json
generated
4269
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -35,6 +35,9 @@
|
|||||||
"typescript": "2.6.1",
|
"typescript": "2.6.1",
|
||||||
"less": "2.7.3",
|
"less": "2.7.3",
|
||||||
"semantic-ui-less": "2.2.14",
|
"semantic-ui-less": "2.2.14",
|
||||||
|
"react": "16.3.1",
|
||||||
|
"@types/react": "16.0.25",
|
||||||
|
"@types/react-dom": "16.0.3",
|
||||||
"@types/bluebird": "2.0.33",
|
"@types/bluebird": "2.0.33",
|
||||||
"@types/jquery": "3.2.16",
|
"@types/jquery": "3.2.16",
|
||||||
"@types/marked": "0.3.0",
|
"@types/marked": "0.3.0",
|
||||||
@ -42,7 +45,7 @@
|
|||||||
"@types/web-bluetooth": "0.0.4"
|
"@types/web-bluetooth": "0.0.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pxt-common-packages": "6.5.3",
|
"pxt-common-packages": "6.5.14",
|
||||||
"pxt-core": "5.5.24"
|
"pxt-core": "5.5.37"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,14 @@ namespace pxsim.serial {
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setRxBufferSize(size: number) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setTxBufferSize(size: number) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
export function readBuffer(length: number) {
|
export function readBuffer(length: number) {
|
||||||
if (length <= 0)
|
if (length <= 0)
|
||||||
length = 64;
|
length = 64;
|
||||||
|
@ -94,3 +94,23 @@
|
|||||||
.ui.downloaddialog.modal>.content {
|
.ui.downloaddialog.modal>.content {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ui.webusbpair, .ui.upload {
|
||||||
|
.firmware {
|
||||||
|
background-color: #FFFFCE;
|
||||||
|
div.image {
|
||||||
|
justify-content: center;
|
||||||
|
display: flex;
|
||||||
|
padding: 1rem;
|
||||||
|
|
||||||
|
img {
|
||||||
|
height:100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.instructions {
|
||||||
|
img {
|
||||||
|
margin-bottom:1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user