[SOLVED] RTOS plugins

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] RTOS plugins

    I'm trying to implement plugin for ThreadX for Ozone. I got threads lists and other object lists working, but can't get it to call getregs. It is never called, I added TargetInterface.message to trace method calls. Any ideas what I could try or what are the conditions for those methods?

    And you could remove all voids from plugin writing documentation, there is no void in JavaScript :D
  • Hello,

    Thank you for your inquiry.
    getregs is called if you select a task in the RTOS window and the selected task is not the currently active context.
    For more information see Ozone manual UM08025 section. 7.10.1.1 Threads.add

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello,

    I just gave it a try with an embOS sample and the embOSPlugin.js Plugin under /Plugins/OS
    There getregs is working and called as expected.
    If I remove the getregs from the script and reload the project the registers will not change if I select a task.
    So getregs is definitely called when everything is implemented correctly.

    We recommend to use the embOSPlugin for reference. Maybe something is not yet correct in your script.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • OK, so I just created absolutely minimal plugin, that should allow switching of the threads.
    And getregs is never called... Ozone V3.22a

    JavaScript Source Code

    1. function init(){
    2. Threads.clear();
    3. Threads.newqueue("Threads");
    4. Threads.setColumns("Thread","Priority","State");
    5. Threads.setSortByNumber("Priority");
    6. Threads.setColor("State", "READY", "EXECUTING", "SLEEP");
    7. }
    8. function update(){
    9. TargetInterface.message("update");
    10. Threads.clear();
    11. Threads.newqueue("Threads");
    12. Threads.add("Thread 1", 1, "EXECUTING", undefined);
    13. Threads.add("Thread 2", 1, "READY", 0x1000);
    14. Threads.add("Thread 3", 1, "SLEEP", 0x2000);
    15. }
    16. function getregs(thread) {
    17. TargetInterface.message("getregs");
    18. return new Array(17);
    19. }
    20. function getname(thread){
    21. TargetInterface.message("getname");
    22. return "name";
    23. }
    24. function getOSName() {
    25. return "Test";
    26. }
    27. function getContextSwitchAddrs(){
    28. TargetInterface.message("getContextSwitchAddrs");
    29. return [
    30. 0x8000
    31. ];
    32. }
    Display All
  • Hello,

    The issue is that you use Threads.newqueue("Threads"); in the init which is incorrect.
    This leads to the effect that the displayed list is no longer a tasklist. The taskswitch can only be resolved within a tasklist.
    See attached the fixed up example.

    As mentioned before we recommend to use the embOS plugin for reference which is working correctly.

    Best regards,
    Nino
    Files
    • thread_new.js

      (2.03 kB, downloaded 311 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Thanks, this helped a lot!
    It would be worth stressing out in documentation you should not change the queue name after clear to get into tasklist. Or that there IS a special qeue name for Tasks.

    Even example does it (note void that are not valid in JS):

    JavaScript Source Code

    1. function init(void)
    2. {
    3. // Init the task table
    4. Threads.newqueue("Tasks");
    5. Threads.setColumns("Name", "Priority", "Status", "Timeout");
    6. Threads.setSortByNumber("Priority");
    7. Threads.setColor("Status", "Ready", "Executing", "Waiting");
    8. }
    9. function update(void)
    10. {
    11. // clear all tables
    12. Threads.clear();
    13. // fill the task table
    14. if (Threads.shown("Tasks")) {
    15. Threads.newqueue("Tasks");
    16. Threads.add("Task1", "0", "Executing", "1000", 0x20003000);
    17. Threads.add("Task2", "1", "Waiting", "2000", aRegs);
    18. }
    19. }
    Display All

    I still don't get valid backtraces but this is the fun part to figure out.
  • Got getregs working properly with ThreadX.
    One more question, what getContextSwitchAddrs actually do? When it is used?
    It looks now that registers are restored properly when I switch tasks, but Call Stack window is not updated on thread switch. Any hints?

    The post was edited 1 time, last by fzawadiak ().

  • Hello,

    Great to hear that you got it up and running and thank you for sharing with the community.
    We will make sure to point users to your github when looking for a ThreadX script.

    Regarding your documentation feedback we will discuss this internally and see where it can be improved further.

    Happy debugging!

    We will consider this thread as solved now.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.