Skip to content

Pass Device Addr (IP:Port) to JRTC Apps#84

Merged
doctorlai-msrc merged 6 commits intomainfrom
zhihua/deviceid
Jul 15, 2025
Merged

Pass Device Addr (IP:Port) to JRTC Apps#84
doctorlai-msrc merged 6 commits intomainfrom
zhihua/deviceid

Conversation

@doctorlai-msrc
Copy link
Copy Markdown
Collaborator

@doctorlai-msrc doctorlai-msrc commented Jul 11, 2025

This PR passes the ip:port/device-id from deployment yaml to the jrtc app env context. This PR also adds assertions in test_apps/first_example_py to make sure these values are passed correctly.

def jrtc_start_app(capsule):
    env_ctx = get_ctx_from_capsule(capsule)
    if not env_ctx:
        raise ValueError("Failed to retrieve JrtcAppEnv from capsule")

    ## Extract necessary fields from env_ctx and make assertions
    app_name = env_ctx.app_name.decode("utf-8")
    io_queue_size = env_ctx.io_queue_size
    app_path = env_ctx.app_path.decode("utf-8")
    app_modules = env_ctx.app_modules
    app_params = env_ctx.params
    device_mapping = env_ctx.device_mapping

    ## assertions
    assert app_name == "app1", f"Unexpected app name: {app_name}"
    assert io_queue_size == 1000, f"Unexpected IO queue size: {io_queue_size}"
    assert app_path.split("/")[-1] == "libjrtc_pythonapp_loader.so", f"Unexpected app path: {app_path}"
    assert app_modules[0].decode("utf-8").split('/')[-1] == "generated_data.py", f"Unexpected first module: {app_modules[0]}"
    assert app_modules[1].decode("utf-8").split('/')[-1] == "simple_input.py", f"Unexpected second module: {app_modules[1]}"
    assert app_params[0].key.decode("utf-8") == "python", f"Unexpected app parameter key: {app_params[0].key}"
    assert app_params[0].value.decode("utf-8").split('/')[-1] == "first_example.py", f"Unexpected app parameter value: {app_params[0].value}"
    assert device_mapping[0].key.decode("utf-8") == "1", f"Unexpected device mapping key: {device_mapping[0].key}"
    assert device_mapping[0].value.decode("utf-8") == "127.0.0.1:8080", f"Unexpected device mapping value: {device_mapping[0].value}"

This PR refactors the function _is_app_loaded()

  1. adding more debug messages,
  2. passing the parameter via Pointer to avoid copy
  3. checking for NULL before calling strcmp

When app_type is "python", the python script is stored in parameters, thus this is used to check if the app has been loaded. For normal C/C++ app, the app is checked via the .so which is stored in app_path.

@doctorlai-msrc doctorlai-msrc changed the title Add tests and GetHostnameFromDeviceId Pass Device Addr (IP:Port) to JRTC Apps Jul 14, 2025
@doctorlai-msrc doctorlai-msrc marked this pull request as ready for review July 14, 2025 13:07
Copy link
Copy Markdown
Collaborator

@bradunov bradunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address my comments

@doctorlai-msrc doctorlai-msrc added this pull request to the merge queue Jul 15, 2025
Merged via the queue into main with commit 76bc2c0 Jul 15, 2025
15 of 16 checks passed
@doctorlai-msrc doctorlai-msrc deleted the zhihua/deviceid branch July 15, 2025 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants