Skip to content
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

add option to not load byte code on target #946

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mobsya-association/thymio-api",
"version": "0.11.0",
"version": "0.11.1",
"description": "A JS api to communicate with Thymio from node and browsers",
"dependencies": {
"@cor3ntin/flexbuffers-wasm": "0.0.18",
Expand Down
19 changes: 10 additions & 9 deletions js/src/thymio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ export interface INode extends IBasicNode {
*
* @see [[lock]]
*/
sendAsebaProgram(code : string) : Promise<any>;
sendAsebaProgram(code : string, dontLoadOnTarget: boolean) : Promise<any>;

/** Run the code currently loaded on the vm
* The device must be locked & ready before calling this function
Expand Down Expand Up @@ -764,8 +764,8 @@ export class Node extends BasicNode implements INode {
return this.group.eventsDescriptions
}

sendAsebaProgram(code : string) {
return this._client._send_program(this._id, code, mobsya.fb.ProgrammingLanguage.Aseba);
sendAsebaProgram(code : string, dontLoadOnTarget: boolean = false) {
return this._client._send_program(this._id, code, mobsya.fb.ProgrammingLanguage.Aseba, dontLoadOnTarget);
}

/** Load an aesl program on the VM
Expand All @@ -774,8 +774,8 @@ export class Node extends BasicNode implements INode {
* @throws {mobsya.fb.Error}
* @see lock
*/
send_aesl_program(code) {
return this._client._send_program(this._id, code, mobsya.fb.ProgrammingLanguage.Aesl);
send_aesl_program(code, dontLoadOnTarget: boolean = false) {
return this._client._send_program(this._id, code, mobsya.fb.ProgrammingLanguage.Aesl, dontLoadOnTarget);
}

runProgram() {
Expand Down Expand Up @@ -1016,8 +1016,7 @@ class Client implements IClient {
let msg = message.message(new mobsya.fb.CompilationResultFailure())
let req = this._get_request(msg.requestId())
if(req) {
//TODO
req._trigger_error("Compilation error")
req._trigger_error(msg.message())
}
break
}
Expand Down Expand Up @@ -1123,7 +1122,7 @@ class Client implements IClient {
return this._prepare_request(req_id)
}

_send_program(id : NodeId, code : string, language : mobsya.fb.ProgrammingLanguage) {
_send_program(id : NodeId, code : string, language : mobsya.fb.ProgrammingLanguage, dontLoadOnTarget: boolean = false) {
const builder = new flatbuffers.Builder();
const req_id = this._gen_request_id()
const codeOffset = builder.createString(code)
Expand All @@ -1133,7 +1132,9 @@ class Client implements IClient {
mobsya.fb.CompileAndLoadCodeOnVM.addNodeId(builder, nodeOffset)
mobsya.fb.CompileAndLoadCodeOnVM.addProgram(builder, codeOffset)
mobsya.fb.CompileAndLoadCodeOnVM.addLanguage(builder, language)
mobsya.fb.CompileAndLoadCodeOnVM.addOptions(builder, mobsya.fb.CompilationOptions.LoadOnTarget)
if (!dontLoadOnTarget){
mobsya.fb.CompileAndLoadCodeOnVM.addOptions(builder, mobsya.fb.CompilationOptions.LoadOnTarget)
}
const offset = mobsya.fb.CompileAndLoadCodeOnVM.endCompileAndLoadCodeOnVM(builder)
this._wrap_message_and_send(builder, offset, mobsya.fb.AnyMessage.CompileAndLoadCodeOnVM)
return this._prepare_request(req_id)
Expand Down