-
Notifications
You must be signed in to change notification settings - Fork 55
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 optional priority attribute for messages #67
base: master
Are you sure you want to change the base?
Conversation
@gautierhattenberger what do you think? |
tools/generator/pprz_parse.py
Outdated
@@ -131,7 +132,8 @@ def start_element(name, attrs): | |||
elif in_element == "protocol.msg_class.message": | |||
check_attrs(attrs, ['name', 'id'], 'message') | |||
if self.current_class == self.class_name: | |||
self.message.append(PPRZMsg(attrs['name'], attrs['id'], p.CurrentLineNumber)) | |||
priority = attrs['priority'] if 'priority' in attrs else 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably easier to write priority = attrs.get('priority', 1)
Should the default really be 1? Is that the lowest, or is 0 also allowed? What are the min and max priorities? How are the priorities actually handled? |
Default can be anything really, 1 is a good number, because 0 indicates "priority not set" which can be useful to know (e.g. when handling errors). It is a priority byte so 0-255 They are not handled in any way right now (the transport layer doesn't care). I used a priority queue for example to test it over serial link, but other ways are possible too. |
Obviously, all transports should implement the new |
The use case I had in mind was to have the priority queue a part of the transport layer. See #70 - the queue is a part of the user code, not directly in pprzlink (I would like to avoid changing the device layer.). OpenDDS (see #69) has a bunch of settings for Quality Of Service, so the priority could nicely fit in there. So it would mean just adding empty |
For me the question also is if this priority attribute is "only" on a per message type basis (according to messages.xml) and thus fixed at compilation time or one can set a prio for a message when sending it... |
The "default" priority is set at compilation time, but it can be changed on runtime if needed (see https://github.com/paparazzi/pprzlink/pull/70/files#diff-88c9c4ad71adde0ca53ec6beafc8750fR51 in #70 ), assuming the message handling code implements it. Although I can't think of a good use case that cannot be done with the default priorities - do you have suggestions? I think I need to add a priority field into the transport struct, so it can be passed with |
@gautierhattenberger any thoughts on this? This could be nicely used in user-defined transport (similar to paparazzi/paparazzi@0e552b4 ) |
I still have one extra concern about the best place to set this priority level. In your current implementation, it is done after the |
I like it to be a part of |
Imagine this use case - there is a priority queue that arranges messages based on their priority and sends them at specific intervals. If the queue is full, but your new message has higher priority than the lowest priority message in the queue, the lowest priority message gets dropped, and the new high priority message will be added. Specifically:
So the takeaway - priority should be checked before starting the message with And on a side note - how do you handle mutexes in ChibiOS logging? |
I would say that if the For ChibiOS, it is actually the device level with the |
OK, I ll update the |
The attribute can be used for QoS if the transport layer implements so.
Default priority is 1, higher number has higher priority.
I added dummy
put_priority()
functions inpprz_transport.c
for now.I did some tests with priority queues, and it works as expected.