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

broken examples #110

Open
douglas-raillard-arm opened this issue Feb 5, 2021 · 2 comments
Open

broken examples #110

douglas-raillard-arm opened this issue Feb 5, 2021 · 2 comments

Comments

@douglas-raillard-arm
Copy link

douglas-raillard-arm commented Feb 5, 2021

"examples/video-short.json" is broken in two ways:

  • It's not valid JSON
  • Once the syntax errors are fixed, it's misleading:
    Phases like this one:

		"NuPlayerDriver1" : {
			"priority" : -15,
			"loop" : -1,
			"suspend",
			"run" : 100,
			"lock" : "NuPlayerDriver",
			"sync" : { "ref" : "NuPlayerDriver", "mutex" : "NuPlayerDriver" },
			"unlock" : "NuPlayerDriver",
			"run" : 50,
			"suspend" : "NuPlayerDriver",
			"run" : 80,
			"lock" : "NuPlayerDriver",
			"sync" : { "ref" : "NuPlayerDriver", "mutex" : "NuPlayerDriver" },
			"unlock" : "NuPlayerDriver",
			"run" : 370,
			"lock" : "NuPlayerDriver",
			"sync" : { "ref" : "NuPlayerDriver", "mutex" : "NuPlayerDriver" },
			"unlock" : "NuPlayerDriver",
			"run" : 135,
			"resume" : "NuPlayerDriver"
		},

are parsed as containing 6 events: duplicated keys are handled by json-c this way:

  • the order is insertion order
  • the value is the value of the last appearance of the key.

This means that the first 2 events will be "suspend" and then "run 135" (135 being the value of the last run). This can be easily observed by running rt-app -l100 video-short.json to get the details of what rt-app is effectively parsing.

This pull request would allow describing such configuration by using an array of events rather than directly have the keys in the phase body: #108

@vingu-linaro
Copy link
Member

One comment about what you stated above: examples/video-short.json is not broken but must be used with workgen script which ensure that each key will be unique. Please read the tutorial.txt :
"
workgen is a python script that will parse, check and update the json like file
in order to strictly match the json grammar before calling rt-app that will
execute the sequence described in it.

Even if the json protocol is used in rt-app, workgen enables some freedom
compared to stricter json grammar rules. For examples,

  • You don't have to ensure uniqueness of key in json object, workgen will check
    the file and ensure that each key is unique by appending an index if necessary.
    The feature is quite useful when you describe a sequence made of same kind of
    events e.g. a sequence of multiple sleep and run events.
  • Some values can be omitted and workgen will add them when it parses the file
    before starting the use case.
    "

@douglas-raillard-arm
Copy link
Author

I realized that after opening the issue but I left it open as the file extension is ".json", which is misleading as:

  • it's not a subset of JSON
  • rt-app do support JSON, which makes it confusing

Maybe just a rename into something like ".workgen-json" or ".json-like" would be enough to avoid the confusion and the screams from text editors attempting syntax highlight on these files.

Alternatively, it looks like they could be converted to actual JSON. After a quick look at workgen sources, it's not unlikely that it can consume actual JSON directly, so the base example would be usable for both:

  • people extending it with workgen syntax
  • people feeding it directly to rt-app

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

No branches or pull requests

2 participants