Add serial support
This commit is contained in:
@ -8,7 +8,11 @@ eval("if (typeof process === 'object' && process + '' === '[object process]') px
|
||||
|
||||
namespace pxt.editor {
|
||||
// this comes from aux/pxt.lms
|
||||
const rbfTemplate = "4c45474f5d0000006d000100000000001c0000000000000008000000821b028405018130813e805374617274696e672e2e2e0084006080XX0044830383010640414082f5ff8405018130813e80427965210084000a";
|
||||
const rbfTemplate = `
|
||||
4c45474f710000006d000100000000001c000000000000000a000000821b028405018130813e8053
|
||||
74617274696e672e2e2e008400c002802f746d702f73657269616c2e74787400486080XX00448303
|
||||
83010640414082f5ff8405018130813e80427965210084000a
|
||||
`
|
||||
|
||||
function hf2Async() {
|
||||
return pxt.HF2.mkPacketIOAsync()
|
||||
@ -44,7 +48,9 @@ namespace pxt.editor {
|
||||
let f = U.stringToUint8Array(atob(resp.outfiles[pxt.outputName()]))
|
||||
return w.flashAsync(elfPath, f)
|
||||
}).then(() => {
|
||||
let rbfHex = rbfTemplate.replace("XX", U.toHex(U.stringToUint8Array(elfPath)))
|
||||
let rbfHex = rbfTemplate
|
||||
.replace(/\s+/g, "")
|
||||
.replace("XX", U.toHex(U.stringToUint8Array(elfPath)))
|
||||
let rbf = U.fromHex(rbfHex)
|
||||
HF2.write16(rbf, 4, rbf.length)
|
||||
return w.flashAsync(rbfPath, rbf)
|
||||
@ -59,10 +65,19 @@ namespace pxt.editor {
|
||||
}
|
||||
|
||||
initExtensionsAsync = function (opts: pxt.editor.ExtensionOptions): Promise<pxt.editor.ExtensionResult> {
|
||||
pxt.debug('loading pxt-adafruit target extensions...')
|
||||
pxt.debug('loading pxt-ev3 target extensions...')
|
||||
const res: pxt.editor.ExtensionResult = {
|
||||
deployCoreAsync,
|
||||
};
|
||||
initAsync()
|
||||
.then(w => w.streamFileAsync("/tmp/serial.txt", buf => {
|
||||
let str = Util.fromUTF8(Util.uint8ArrayToString(buf))
|
||||
window.postMessage({
|
||||
type: 'serial',
|
||||
id: 'n/a', // TODO
|
||||
data: str
|
||||
}, "*")
|
||||
}))
|
||||
return Promise.resolve<pxt.editor.ExtensionResult>(res);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user