{"action":"created","issue":{"url":"https://api.github.com/repos/aseba-community/aseba-target-thymio2/issues/17","repository_url":"https://api.github.com/repos/aseba-community/aseba-target-thymio2","labels_url":"https://api.github.com/repos/aseba-community/aseba-target-thymio2/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/aseba-community/aseba-target-thymio2/issues/17/comments","events_url":"https://api.github.com/repos/aseba-community/aseba-target-thymio2/issues/17/events","html_url":"https://github.com/aseba-community/aseba-target-thymio2/issues/17","id":174800424,"number":17,"title":"New native function to load a bytecode, from memory or from SD","user":{"login":"davidjsherman","id":9472510,"avatar_url":"https://avatars.githubusercontent.com/u/9472510?v=3","gravatar_id":"","url":"https://api.github.com/users/davidjsherman","html_url":"https://github.com/davidjsherman","followers_url":"https://api.github.com/users/davidjsherman/followers","following_url":"https://api.github.com/users/davidjsherman/following{/other_user}","gists_url":"https://api.github.com/users/davidjsherman/gists{/gist_id}","starred_url":"https://api.github.com/users/davidjsherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidjsherman/subscriptions","organizations_url":"https://api.github.com/users/davidjsherman/orgs","repos_url":"https://api.github.com/users/davidjsherman/repos","events_url":"https://api.github.com/users/davidjsherman/events{/privacy}","received_events_url":"https://api.github.com/users/davidjsherman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-02T16:35:52Z","updated_at":"2016-09-05T09:02:41Z","closed_at":null,"body":"I propose a new, hidden system function `_bytecode.load(number)` that resets the VM an loads a new bytecode into memory. It would work analogously to the `sound.{system,record,replay,play}` functions:\r\n 1. if a file named `Ax.abo` exists on the SD, load it\r\n 1. if `x` = 0 and `vmcode.abo` exists on the SD, load it\r\n 1. otherwise, if `x` is in 0–6, load the corresponding system bytecode\r\n  * 0: initial menu, 1: friendly, 2: explorer, 3:fearful, 4: attentive, 5: investigator, 6: obedient\r\n 1. otherwise, beep (play note A4 for 10)\r\n\r\nThere is no `_bytecode.save`! Bytecodes cannot be written by programs, they must be saved on SD cards.\r\n\r\nPre-compiled byte codes can be added to the firmware with a new `static const struct bytecode`, analogous to `static const struct music` in `playback.c`.\r\n\r\nFirmware 10 has the initial menu interface and default LED behavior hard-coded in `behavior.c`, and the six basic behaviors are hard-coded in C in `mode.c`. This is hard to maintain. There is no guarantee that the hard-coded behaviors can be imitated by student programmers in Aesl. With this function and steps 3–4, above, one could replace the behaviors written in C with stored bytecodes that were generated from Aesl programs.\r\n\r\nWith this function and steps 1–2, above, one could update the standard behaviors by placing the improved bytecode files on the SD.\r\n\r\nThis function could furthermore be used to define a new second-stage boot loader, replacing the initial menu system. Bytecode `vmcode.abo` on the SD card is run automatically and could present a different menu system, with a different choice of pre-programmed behaviors.\r\n\r\nThe other standard behaviors, such as updating the charging LEDs and changing the circle LEDs according to the accelerometer, should still be implemented in `behavior.c`."},"comment":{"url":"https://api.github.com/repos/aseba-community/aseba-target-thymio2/issues/comments/244695910","html_url":"https://github.com/aseba-community/aseba-target-thymio2/issues/17#issuecomment-244695910","issue_url":"https://api.github.com/repos/aseba-community/aseba-target-thymio2/issues/17","id":244695910,"user":{"login":"davidjsherman","id":9472510,"avatar_url":"https://avatars.githubusercontent.com/u/9472510?v=3","gravatar_id":"","url":"https://api.github.com/users/davidjsherman","html_url":"https://github.com/davidjsherman","followers_url":"https://api.github.com/users/davidjsherman/followers","following_url":"https://api.github.com/users/davidjsherman/following{/other_user}","gists_url":"https://api.github.com/users/davidjsherman/gists{/gist_id}","starred_url":"https://api.github.com/users/davidjsherman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidjsherman/subscriptions","organizations_url":"https://api.github.com/users/davidjsherman/orgs","repos_url":"https://api.github.com/users/davidjsherman/repos","events_url":"https://api.github.com/users/davidjsherman/events{/privacy}","received_events_url":"https://api.github.com/users/davidjsherman/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T09:02:41Z","updated_at":"2016-09-05T09:02:41Z","body":"This original idea comes from aseba-community/aseba#550, because the simulator does not have the target-thymio2 firmware code. So we will probably implement it this was in the simulator, since it is easier to write an Aesl program to simulate the initial menu than it is to simulate the PIC24 firmware.\r\n\r\nIf you prefer, in the real robot, we could disallow `x` = 0–6 in order to guarantee that the basic behaviors are always available. A0 is a reset to the initial menu, A1–A6 are the basic behaviors, in whatever way they are implemented in the firmware.\r\n\r\nI don't think that we should try to suggest that one can change the basic behaviors! It is a consequence that, **if** an SD card has a `vmcode.abo` that is started automatically, **and** that `vmcode.abo` can use `_bytecode.load(x)` to freely load another bytecode from the SD card, **then** the startup behavior of the robot ***could*** imitate a different initial menu.\r\n\r\nBut the hardcoded initial menu is always there, if the SD card is removed.\r\n\r\nSince the system function is hidden, it will only be used by those who have read the documentation and its warnings against confusing the innocent."}}
{"actor":{"display_login":"davidjsherman"}}