GobySoft / dccl

Dynamic Compact Control Language
Other
17 stars 13 forks source link

dccl tool analyze still outputs information on invalid messages #124

Closed tsaubergine closed 10 months ago

tsaubergine commented 10 months ago

For example:

[toby@aubergine ~/opensource/jaiabot/src/lib/messages] dccl -a -f arduino.proto   
Not a valid DCCL message: jaiabot.protobuf.ArduinoActuators
Why: Message: jaiabot.protobuf.ArduinoActuators: Missing message option `(dccl.msg).id`. Specify a unique id (e.g. 3) in the body of your .proto message using "option (dccl.msg).id = 3"
Not a valid DCCL message: jaiabot.protobuf.ArduinoCommand
Why: Message: jaiabot.protobuf.ArduinoCommand: Missing message option `(dccl.msg).id`. Specify a unique id (e.g. 3) in the body of your .proto message using "option (dccl.msg).id = 3"
Not a valid DCCL message: jaiabot.protobuf.ArduinoResponse
Why: Message: jaiabot.protobuf.ArduinoResponse: Missing message option `(dccl.msg).id`. Specify a unique id (e.g. 3) in the body of your .proto message using "option (dccl.msg).id = 3"
Not a valid DCCL message: jaiabot.protobuf.ArduinoSettings
Why: Message: jaiabot.protobuf.ArduinoSettings: Missing message option `(dccl.msg).id`. Specify a unique id (e.g. 3) in the body of your .proto message using "option (dccl.msg).id = 3"
============ 0: jaiabot.protobuf.ArduinoActuators ============
Actual maximum size of message: 2 bytes / 16 bits
        dccl.id head...........................8
        user head..............................0
        body...................................1
        padding to full byte...................7
Allowed maximum size of message: 0 bytes / 0 bits
--------------------------- Header ---------------------------
dccl.id head...................................8 {dccl.default.id}
---------------------------- Body ----------------------------
jaiabot.protobuf.ArduinoActuators..............1 {dccl.default2}
        6. led_switch_on.......................1 {dccl.default2}
============= 0: jaiabot.protobuf.ArduinoCommand =============
Actual maximum size of message: 2 bytes / 16 bits
        dccl.id head...........................8
        user head..............................0
        body...................................1
        padding to full byte...................7
Allowed maximum size of message: 0 bytes / 0 bits
--------------------------- Header ---------------------------
dccl.id head...................................8 {dccl.default.id}
---------------------------- Body ----------------------------
jaiabot.protobuf.ArduinoCommand................1 {dccl.default2}
        2. actuators...........................1 {dccl.default2}
                6. led_switch_on.......................1 {dccl.default2}
============ 0: jaiabot.protobuf.ArduinoResponse ============
Actual maximum size of message: 2 bytes / 16 bits
        dccl.id head...........................8
        user head..............................0
        body...................................7
        padding to full byte...................1
Allowed maximum size of message: 0 bytes / 0 bits
--------------------------- Header ---------------------------
dccl.id head...................................8 {dccl.default.id}
---------------------------- Body ----------------------------
jaiabot.protobuf.ArduinoResponse...............7 {dccl.default2}
        2. thermocouple_temperature_C..........1 {dccl.default2}
        3. vccvoltage..........................1 {dccl.default2}
        4. vcccurrent..........................1 {dccl.default2}
        5. vvcurrent...........................1 {dccl.default2}
        50. crc................................1 {dccl.default2}
        51. calculated_crc.....................1 {dccl.default2}
        52. version............................1 {dccl.default2}
============ 0: jaiabot.protobuf.ArduinoSettings ============
Actual maximum size of message: 1 bytes / 8 bits
        dccl.id head...........................8
        user head..............................0
        body...................................0
        padding to full byte...................0
Allowed maximum size of message: 0 bytes / 0 bits
--------------------------- Header ---------------------------
dccl.id head...................................8 {dccl.default.id}
---------------------------- Body ----------------------------
psmskelton commented 10 months ago

Likely only an issue in the tool, correct? Or do you think it's poor behaviour in dccl::Codec::info and perhaps it should check validity also?

The tool would be easy enough to patch around, but would still want all messages to throw their errors, IMO, so a flag around:

https://github.com/GobySoft/dccl/blob/d7c89774b68a031929e634f9d4a668659e52c5d0/src/apps/dccl/dccl_tool.cpp#L178-L184

With appropriate checks on encode, decode, and analyze in:

https://github.com/GobySoft/dccl/blob/d7c89774b68a031929e634f9d4a668659e52c5d0/src/apps/dccl/dccl_tool.cpp#L188-L190

Would likely work, except load_desc() is a void, so that can either be changed to bool and return false or pass by reference and set the flag to false on the error condition:

https://github.com/GobySoft/dccl/blob/d7c89774b68a031929e634f9d4a668659e52c5d0/src/apps/dccl/dccl_tool.cpp#L430-L434