-
Notifications
You must be signed in to change notification settings - Fork 43
Bump pxt 12.x and some other changes #1052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
THEb0nny
wants to merge
65
commits into
microsoft:master
Choose a base branch
from
THEb0nny:bump-pxt-10
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
118e7af
consume-pxteditor-changes-and-upgrade-code
THEb0nny f02e716
Update deploy.ts
THEb0nny 20158f9
pxt-core-and-common-packages-bump
THEb0nny 969d2e5
Update extension.ts
THEb0nny 6ac7b2e
Update field_music.ts
THEb0nny c6f7cb1
Update field_ports.ts
THEb0nny c0a712c
Update field_music.ts
THEb0nny 5816038
Update field_color.ts
THEb0nny 53a46bf
Update field_music.ts
THEb0nny 62efa39
Update field_music.ts
THEb0nny 536dbad
Update field_motors.ts
THEb0nny 23e2f7c
Update field_brickbuttons.ts
THEb0nny 9bf4852
Update field_motors.ts
THEb0nny e67e668
Update field_ports.ts
THEb0nny bc459b5
del_field_ports
THEb0nny dbaff3f
Update field_brickbuttons.ts
THEb0nny ec13cf1
Update ultrasonic.ts
THEb0nny 83c0e91
Update field_color.ts
THEb0nny 329bd21
turnRatio-del
THEb0nny 0c685bc
Update field_color.ts
THEb0nny c63d81e
return-applyColour()
THEb0nny cd9b5fe
bump_10-0-13
THEb0nny 54eb2e5
bump-10-0-14
THEb0nny 679c698
bump-10-0-16
THEb0nny ee43257
bump-10.0.18
THEb0nny 2ca3b41
bump-pxt-10.0.20
THEb0nny e5d1ff7
fix-button-select
THEb0nny a6b84b0
Update field_brickbuttons.ts
THEb0nny 2e52c18
additions-for-downloading-bluetooth
THEb0nny e2ce518
add-functionality-and-upgrade -motors-blocks
THEb0nny 15d278e
bump-pxt-10.0.23
THEb0nny 6eb8fdb
Update output.ts
THEb0nny ffaeb88
bump-pxt-10.2.3-and-common-packages-10.0.3
THEb0nny 6c1e22e
bump-pxt-core-10.2.15
THEb0nny 935be39
bump-pxt-10.3.8-and-common-packages-12.1.1
THEb0nny 9eb35cc
bump-pxt-11.2.3
THEb0nny d15e682
bump_pxt_11.2.10
THEb0nny bcb9af8
downloadArea-delete-fill
THEb0nny ac75468
bump-pxt-10.2.15
THEb0nny a312679
Update light.ts
THEb0nny 9cdace9
suppo-undetectable-analog-sensors
THEb0nny 4bc9901
bump_pxt_11.2.20
THEb0nny 200746f
bump-pxt-11.3.4-and-common-packages-12.2.1
THEb0nny 8003521
bump-pxt-11.4.7-and-common-packages-12.3.5
THEb0nny 5fd4c91
Update storage-core.ts
THEb0nny d846656
bump-pxt-11.4.28-and-common-packages-12.3.31
THEb0nny c77058b
Update field_motors.ts
THEb0nny 0d0b93c
Update field_brickbuttons.ts
THEb0nny 419f6d9
Update field_brickbuttons.ts
THEb0nny 0cad591
Update field_music.ts
THEb0nny df15c6d
Update storage-core.ts
THEb0nny 72cb0d2
Update field_motors.ts, field_music.ts
THEb0nny f5ff38f
Update field_music.ts
THEb0nny 0548d6b
Update field_music.ts
THEb0nny 251c326
theme-support
THEb0nny 0932aab
Update field_music.ts
THEb0nny 58a22a9
Update field_music.ts
THEb0nny b34009d
Bluetooth log fix and improvements
THEb0nny ac0cd8e
Update deploy.ts
THEb0nny c0f295a
allow_underscores_in_filename
THEb0nny b028d10
bump-pxt-11.4.40
THEb0nny 69de621
Update blockly.less
THEb0nny 9a02f69
changes_in_MMapMethods.buf()_for_sim_recovery
THEb0nny 650b8a1
bump-pxt-12.1.5-and-common-packages-13.1.0
THEb0nny 35e898d
bump-pxt-12.2.8-and-common-packages-13.1.4
THEb0nny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| /// <reference path="../node_modules/pxt-core/built/pxteditor.d.ts"/> | ||
| /// <reference path="../node_modules/pxt-core/localtypings/pxteditor.d.ts"/> | ||
| /// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/> | ||
|
|
||
| import HF2 = pxt.HF2; | ||
|
|
@@ -14,6 +14,7 @@ export function debug() { | |
| } | ||
|
|
||
| // Web Serial API https://wicg.github.io/serial/ | ||
| // https://www.npmjs.com/package/@types/web-bluetooth | ||
| // chromium bug https://bugs.chromium.org/p/chromium/issues/detail?id=884928 | ||
| // Under experimental features in Chrome Desktop 77+ | ||
| enum ParityType { | ||
|
|
@@ -23,6 +24,7 @@ enum ParityType { | |
| "mark", | ||
| "space" | ||
| } | ||
|
|
||
| declare interface SerialOptions { | ||
| baudRate?: number; | ||
| databits?: number; | ||
|
|
@@ -34,15 +36,18 @@ declare interface SerialOptions { | |
| xoff?: boolean; | ||
| xany?: boolean; | ||
| } | ||
|
|
||
| type SerialPortInfo = pxt.Map<string>; | ||
| type SerialPortRequestOptions = any; | ||
|
|
||
| declare class SerialPort { | ||
| open(options?: SerialOptions): Promise<void>; | ||
| close(): void; | ||
| readonly readable: any; | ||
| readonly writable: any; | ||
| //getInfo(): SerialPortInfo; | ||
| // getInfo(): SerialPortInfo; | ||
| } | ||
|
|
||
| declare interface Serial extends EventTarget { | ||
| onconnect: any; | ||
| ondisconnect: any; | ||
|
|
@@ -60,29 +65,40 @@ class WebSerialPackageIO implements pxt.packetio.PacketIO { | |
| private _writer: any; | ||
|
|
||
| constructor(private port: SerialPort, private options: SerialOptions) { | ||
| console.log(`serial: new io`) | ||
| console.log(`serial: New io`) | ||
| } | ||
|
|
||
| bufferSize(buffer: Uint8Array) { | ||
| return HF2.read16(buffer, 0) + 2; | ||
| } | ||
|
|
||
| async readSerialAsync() { | ||
| this._reader = this.port.readable.getReader(); | ||
| let buffer: Uint8Array; | ||
| const reader = this._reader; | ||
| while (reader === this._reader) { // will change if we recycle the connection | ||
| const { done, value } = await this._reader.read() | ||
| const { done, value } = await this._reader.read(); | ||
| if (!buffer) buffer = value; | ||
| else { // concat | ||
| let tmp = new Uint8Array(buffer.length + value.byteLength) | ||
| tmp.set(buffer, 0) | ||
| tmp.set(value, buffer.length) | ||
| let tmp = new Uint8Array(buffer.length + value.byteLength); | ||
| tmp.set(buffer, 0); | ||
| tmp.set(value, buffer.length); | ||
| buffer = tmp; | ||
| } | ||
| if (buffer) { | ||
| let size = HF2.read16(buffer, 0); | ||
| if (buffer.length == size + 2) { | ||
| let size = this.bufferSize(buffer); | ||
| if (buffer.length == size) { | ||
| this.onData(new Uint8Array(buffer)); | ||
| buffer = undefined; | ||
| } else if (buffer.length > size) { | ||
| console.warn(`Received larger bufer then command command: ${buffer.length} recieved but waiting for ${size}`); | ||
| let tmp = buffer.slice(0, size - 1); | ||
| this.onData(new Uint8Array(tmp)); | ||
| tmp = buffer.slice(size, buffer.length - 1); | ||
| buffer = tmp; | ||
| console.debug(`Next buffer size: ${this.bufferSize(buffer)}`); | ||
| } else { | ||
| console.warn("Incomplete command " + size); | ||
| console.warn(`Incomplete command: ${buffer.length} recieved but waiting for ${size}. Keep waiting...`); | ||
|
Comment on lines
+94
to
+101
|
||
| } | ||
| } | ||
| } | ||
|
|
@@ -93,11 +109,14 @@ class WebSerialPackageIO implements pxt.packetio.PacketIO { | |
| } | ||
|
|
||
| static portIos: WebSerialPackageIO[] = []; | ||
|
|
||
| static async mkPacketIOAsync(): Promise<pxt.packetio.PacketIO> { | ||
| const serial = (<any>navigator).serial; | ||
| if (serial) { | ||
| try { | ||
| const requestOptions: SerialPortRequestOptions = {}; | ||
| const requestOptions: SerialPortRequestOptions = { | ||
| // filters: [{ usbVendorId: 0x0694, usbProductId: 0x0005 }], | ||
| }; | ||
| const port = await serial.requestPort(requestOptions); | ||
|
|
||
| let io = WebSerialPackageIO.portIos.filter(i => i.port == port)[0]; | ||
|
|
@@ -111,7 +130,7 @@ class WebSerialPackageIO implements pxt.packetio.PacketIO { | |
| } | ||
| return io; | ||
| } catch (e) { | ||
| console.log(`connection error`, e) | ||
| console.log(`Connection error`, e) | ||
| } | ||
| } | ||
| throw new Error("could not open serial port"); | ||
|
|
@@ -123,7 +142,8 @@ class WebSerialPackageIO implements pxt.packetio.PacketIO { | |
| } | ||
|
|
||
| private openAsync() { | ||
| console.log(`serial: opening port`) | ||
| console.log(`serial: Opening port`); | ||
| // this.io.onConnectionChanged(); | ||
| if (!!this._reader) return Promise.resolve(); | ||
| this._reader = undefined; | ||
| this._writer = undefined; | ||
|
|
@@ -189,6 +209,7 @@ function hf2Async() { | |
|
|
||
| let useHID = false; | ||
| let useWebSerial = false; | ||
|
|
||
| export function initAsync(): Promise<void> { | ||
| if (pxt.U.isNodeJS) { | ||
| // doesn't seem to work ATM | ||
|
|
@@ -234,6 +255,7 @@ async function cleanupAsync() { | |
| } | ||
|
|
||
| let initPromise: Promise<Ev3Wrapper> | ||
|
|
||
| function initHidAsync() { // needs to run within a click handler | ||
| if (initPromise) | ||
| return initPromise | ||
|
|
@@ -261,6 +283,7 @@ const rbfTemplate = ` | |
| 4c45474f580000006d000100000000001c000000000000000e000000821b038405018130813e8053 | ||
| 74617274696e672e2e2e0084006080XX00448581644886488405018130813e80427965210084000a | ||
| ` | ||
|
|
||
| export function deployCoreAsync(resp: pxtc.CompileResult) { | ||
| let filename = resp.downloadFileBaseName || "pxt" | ||
| filename = filename.replace(/^lego-/, "") | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
slice(0, size - 1)drops the last byte of the intended payload. It should beslice(0, size)to include all bytes of the frame header and body.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember what this change was connected with, but Bluetooth download didn't break for me.