Re: [agl-dev-community] Converting canoe xml to json #help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

after some tests, I found some problems but the base are fine to me :)

Ideed, using the commit you provide I managed to generate the JSON file to be used by the generator but I don't understand some of the objects you generate.

By example, the header seems to always be the same:

{"name": "example",
 "version": "2.0",
 "extra_sources": ["handlers.cpp"],
 "initializers": ["initializeMyStuff"],
 "loopers": ["myLooper"],
 "buses": {
   "hs": {
     "controller": 1, "speed": 500000
   },
   "ms": {
     "controller": 2, "speed": 125000
   }
 },
 "commands": [{
   "name": "turn_signal_status",
   "handler": "handleTurnSignalCommand"
 }],

This parts seems to come from the OpenXC project examples. Which is fine but doesn't fit when you need to generate from a dbc file which does not provide such information.

Then if you want to use them, you should pass them using parameters. Your proposal seems good to me, if we can associate a dbc file with a CAN bus provided by a parameter would be sufficient.

Such mapping would be fine and may be why not be able to append signals to an existing generated file. Example:

python3 dbc2json_converter.py -i ~/Downloads/opendbc/toyota_prius_2017_can1.dbc:hs -i ~/Downloads/opendbc/toyota_prius_2017_can0.dbc:ls

Here that map can1 with hs bus and can0 with ls. Simple.

So, the header of generated JSON shouldn't be static and use of some kind of mapping between dbc file with CAN buses names.

Howevern using the master branch of opendbc project, I still got the following error:

Traceback (most recent call last):
  File "dbc2json_converter.py", line 178, in <module>
    main(sys.argv[1:])
  File "dbc2json_converter.py", line 74, in main
    db = cantools.database.load_file(inputfile)
  File "/home/claneys/.local/lib/python3.7/site-packages/cantools/database/__init__.py", line 180, in load_file
    strict)
  File "/home/claneys/.local/lib/python3.7/site-packages/cantools/database/__init__.py", line 255, in load
    strict)
  File "/home/claneys/.local/lib/python3.7/site-packages/cantools/database/__init__.py", line 344, in load_string
    raise UnsupportedDatabaseFormatError(e_arxml, e_dbc, e_kcd, e_sym, e_cdd)
cantools.database.UnsupportedDatabaseFormatError: DBC: "Invalid syntax at line 4, column 1: ">>!<<CM_ "Imported file _comma.dbc starts here"""

I suspect a problem parsing the newline as my debug stop in the dbc Parser.py matching '\n' character.

Regards.

Romain.

On 18/05/2020 15:31, walzert wrote:
Hello Romain,
thank you for your words and the testing.
I made a short test with:
opendbc-b9a00d36f23453670d604afd333df33c3325692b/toyota_prius_2017_can1.dbc 
opendbc-b9a00d36f23453670d604afd333df33c3325692b/toyota_prius_2017_can0.dbc 

Could you do the same on your computer and test if the messages are usable for agl-low-can-generator?

---
python3 dbc2json_converter.py -i ~/Downloads/opendbc-b9a00d36f23453670d604afd333df33c3325692b/toyota_prius_2017_can1.dbc 
Number of messages 19
Finished

python3 dbc2json_converter.py -i ~/Downloads/opendbc-b9a00d36f23453670d604afd333df33c3325692b/toyota_prius_2017_can0.dbc 
Number of messages 16
Finished
---

What I forgot at the moment is setting the right bus maybe you could do that by hand or change it in my script as default value in line 108.
I have an concept in my mind that will have different can-files for the different bus, I would add a parameter for the bus e.g. "hs" or "ls" in the script as an arg.

It would be nice if it will working for you and you can generate the right .cpp

Thank you
Thomas
-- 
Romain Forlot - Embedded Engineer - IoT.bzh
romain.forlot@xxxxxxx - www.iot.bzh - +33675142438 
_._,_._,_

Links:

You receive all messages sent to this group.

View/Reply Online (#8366) | Reply To Group | Reply To Sender | Mute This Topic | New Topic
Mute #help
Your Subscription | Contact Group Owner | Unsubscribe [list-automotive-discussions82@xxxxxxxxxxx]

_._,_._,_

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux