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 an option to output JSON #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tkfu
Copy link
Contributor

@tkfu tkfu commented Jun 27, 2023

I didn't want to mess with the arg parsing, so I did this via environment variable.

This would potentially be useful if we want to upload this data to the platform in a (semi-)structured way.

Example output of JSON_OUTPUT=1 tdx-info:

{
  "software": {
    "bootloader": "U-Boot",
    "kernel-version": "5.15.77-6.2.0-devel+git.2276f375f152 #1-TorizonCore SMP PREEMPT Mon Apr 3 13:46:31 UTC 2023",
    "kernel-command-line": "root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.0/torizon/8a048e8dcd63f44d9e7d1cf73385f003c2f36f89ea0a09cf246f3851e081a960/0",
    "distro-name": "NAME=\"TorizonCore\"",
    "distro-version": "VERSION_ID=6.2.0-devel-20230405-build.231",
    "hostname": "testdevice"  },
  "hardware": {
    "hw-model": "Toradex Apalis iMX8QM V1.1 on Apalis Evaluation Board",
    "toradex-version": "0037 V1.1B",
    "serial-number": "06804711",
    "processor-arch": "aarch64"  }
}

Example output of JSON_OUTPUT=1 tdx-info -dt (to show multi-line output in the JSON:

{
  "device-tree": {
    "device-tree-enabled": "imx8qm-apalis-v1.1-eval.dtb",
    "compatible-string": "toradex,apalis-imx8-v1.1-evaltoradex,apalis-imx8-v1.1fsl,imx8qm",
    "device-trees-available": "imx8qm-apalis-eval.dtb\nimx8qm-apalis-ixora-v1.1.dtb\nimx8qm-apalis-v1.1-eval.dtb\nimx8qm-apalis-v1.1-ixora-v1.1.dtb\nimx8qm-apalis-v1.1-ixora-v1.2.dtb\nimx8qp-apalis-v1.1-eval.dtb\nimx8qp-apalis-v1.1-ixora-v1.1.dtb\nimx8qp-apalis-v1.1-ixora-v1.2.dtb"  },
  "device-tree-overlays": {
    "overlays-enabled": "fdt_overlays=apalis-imx8_hdmi_overlay.dtbo apalis-imx8_spi1_spidev_overlay.dtbo apalis-imx8_spi2_spidev_overlay.dtbo",
    "overlays-available": "apalis-imx8_ar0521_overlay.dtbo\napalis-imx8_hdmi_overlay.dtbo\napalis-imx8_mezzanine_can_overlay.dtbo\napalis-imx8_mezzanine_ov5640_overlay.dtbo\napalis-imx8_mezzanine_panel-cap-touch-10inch-lvds_overlay.dtbo\napalis-imx8_ov5640_overlay.dtbo\napalis-imx8_panel-cap-touch-10inch-lvds_overlay.dtbo\napalis-imx8_panel-lvds-dual-channel-1080p_overlay.dtbo\napalis-imx8_resistive-touch_overlay.dtbo\napalis-imx8_spi1_spidev_overlay.dtbo\napalis-imx8_spi2_spidev_overlay.dtbo"  }
}

@microhobby
Copy link
Member

@tkfu This should be very useful indeed. But, what about add a parameter switch instead of the environment variable?

@tkfu
Copy link
Contributor Author

tkfu commented Jun 27, 2023

@microhobby The script as is doesn't do proper arg parsing--it just has a case on $1 instead of consuming $@ via shift as is usually done. So adding an optional flag would have meant also changing the arg-parsing bit. And to be perfectly honest, I just didn't want to do it, especially because I didn't know if there was a reason why the arg parsing was implemented that way (e.g. POSIX compatibility).

microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Jul 6, 2023
@microhobby
Copy link
Member

@tkfu I think I get an unexpected behavior:

When getting the help with the JSON_OUTPUT set:

{
Usage: tdx-info [OPTION]
List information about hardware and software from Toradex modules.

If no parameter was passed, this script will display hardware and software information by default.
--bootloader, -b   : Display bootloader related information (U-Boot and GRUB only).
--devices, -d      : List all devices in /dev/.
--device-tree, -dt : Display device tree and overlays related information.
--dmesg, -dm       : Export the dmesg output in a txt file at ~.
--hardware, -w     : Display only hardware information.
--help, -h         : Display this message.
--no-devices, -nd  : Diplay hardware and software information without listing devices.
--software, -s     : Display only software information.
--all, -a          : Display all information showed above without the dmesg log.


}

It's add it to the blocks, but the result is not a valid JSON.

microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Jul 27, 2023
microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Oct 3, 2023
leonheldattoradex pushed a commit to leonheldattoradex/meta-common-torizon that referenced this pull request Dec 13, 2023
leonheldattoradex pushed a commit to leonheldattoradex/meta-common-torizon that referenced this pull request Dec 15, 2023
leonheldattoradex pushed a commit to leonheldattoradex/meta-common-torizon that referenced this pull request Dec 15, 2023
microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Jan 11, 2024
leonheldattoradex pushed a commit to leonheldattoradex/meta-common-torizon that referenced this pull request Feb 5, 2024
microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Feb 21, 2024
microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Mar 19, 2024
@microhobby
Copy link
Member

Dear maintainers, I think that this was already merged right?

microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Sep 18, 2024
microhobby added a commit to commontorizon/meta-common-torizon that referenced this pull request Sep 19, 2024
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