Merge pull request #51 from Microsoft/debugging

Add debug function
This commit is contained in:
Caitlin Hennessy 2017-11-20 10:54:44 -08:00 committed by GitHub
commit 52816e6de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -9,6 +9,13 @@ eval("if (typeof process === 'object' && process + '' === '[object process]') px
namespace pxt.editor { namespace pxt.editor {
import UF2 = pxtc.UF2; import UF2 = pxtc.UF2;
export let ev3: Ev3Wrapper
export function debug() {
return initAsync()
.then(w => w.downloadFileAsync("/tmp/dmesg.txt", v => console.log(pxt.Util.uint8ArrayToString(v))))
}
// this comes from aux/pxt.lms // this comes from aux/pxt.lms
const rbfTemplate = ` const rbfTemplate = `
4c45474f580000006d000100000000001c000000000000000e000000821b038405018130813e8053 4c45474f580000006d000100000000001c000000000000000e000000821b038405018130813e8053
@ -19,6 +26,7 @@ namespace pxt.editor {
return pxt.HF2.mkPacketIOAsync() return pxt.HF2.mkPacketIOAsync()
.then(h => { .then(h => {
let w = new Ev3Wrapper(h) let w = new Ev3Wrapper(h)
ev3 = w
return w.reconnectAsync(true) return w.reconnectAsync(true)
.then(() => w) .then(() => w)
}) })

View File

@ -252,6 +252,13 @@ namespace pxt.editor {
return loop() return loop()
} }
downloadFileAsync(path: string, cb: (d: Uint8Array) => void) {
return this.lock.enqueue("file", () =>
this.streamFileOnceAsync(path, cb))
}
private initAsync() { private initAsync() {
return Promise.resolve() return Promise.resolve()
} }