ping-protocol icon indicating copy to clipboard operation
ping-protocol copied to clipboard

template: |sort in template creates enum sorted by name and not by value

Open patrickelectric opened this issue 6 years ago • 1 comments

From: https://github.com/bluerobotics/ping-protocol/issues/108

We are sorting the template in alphabetic order and not with #id number. For a better code reading, we should move it somehow to sort the template by #id.

What is happening with |sort:

enum msg_CommonMessage_id {
    Ack = 1,
    Ascii_text = 3,
    Nack = 2,
    Protocol_version = 5,
    Request = 4,
};

without |sort:

enum msg_CommonMessage_id {
    Ack = 1,
    Nack = 2,
    Ascii_text = 3,
    Request = 4,
    Protocol_version = 5,
};

Originally this was an attempt do create the same output with python2 and python3.

patrickelectric avatar Apr 02 '19 17:04 patrickelectric

I think the bigger issue might be that the json are keyed by name instead of id#.

I think keying the json by id, or restructuring the json generally could be the real fix

Putting a python3 restriction on this repository is the quickest/easiest and we should do it in any case

jaxxzer avatar Apr 02 '19 19:04 jaxxzer