Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Best way to parse Arduino boards.txt
Forum Updated to NodeBB v4.3 + New Features

Best way to parse Arduino boards.txt

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 563 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark81
    wrote on 31 Mar 2022, 12:52 last edited by
    #1

    Here a sample of the Arduino boards.txt file:

    ##############################################################
    
    yun.name=Arduino Yún
    yun.upload.via_ssh=true
    
    yun.vid.0=0x2341
    yun.pid.0=0x0041
    yun.vid.1=0x2341
    yun.pid.1=0x8041
    yun.vid.2=0x2A03
    yun.pid.2=0x0041
    yun.vid.3=0x2A03
    yun.pid.3=0x8041
    yun.upload_port.0.vid=0x2341
    yun.upload_port.0.pid=0x0041
    yun.upload_port.1.vid=0x2341
    yun.upload_port.1.pid=0x8041
    yun.upload_port.2.vid=0x2A03
    yun.upload_port.2.pid=0x0041
    yun.upload_port.3.vid=0x2A03
    yun.upload_port.3.pid=0x8041
    yun.upload_port.4.board=yun
    
    yun.upload.tool=avrdude
    yun.upload.tool.default=avrdude
    yun.upload.tool.network=arduino_ota
    yun.upload.protocol=avr109
    yun.upload.maximum_size=28672
    yun.upload.maximum_data_size=2560
    yun.upload.speed=57600
    yun.upload.disable_flushing=true
    yun.upload.use_1200bps_touch=true
    yun.upload.wait_for_upload_port=true
    
    yun.bootloader.tool=avrdude
    yun.bootloader.tool.default=avrdude
    yun.bootloader.low_fuses=0xff
    yun.bootloader.high_fuses=0xd8
    yun.bootloader.extended_fuses=0xfb
    yun.bootloader.file=caterina/Caterina-Yun.hex
    yun.bootloader.noblink=caterina/Caterina-Yun-noblink.hex
    yun.bootloader.unlock_bits=0x3F
    yun.bootloader.lock_bits=0x2F
    
    yun.build.mcu=atmega32u4
    yun.build.f_cpu=16000000L
    yun.build.vid=0x2341
    yun.build.pid=0x8041
    yun.build.usb_product="Arduino Yun"
    yun.build.board=AVR_YUN
    yun.build.core=arduino
    yun.build.variant=yun
    yun.build.extra_flags={build.usb_flags}
    
    ##############################################################
    
    uno.name=Arduino Uno
    
    uno.vid.0=0x2341
    uno.pid.0=0x0043
    uno.vid.1=0x2341
    uno.pid.1=0x0001
    uno.vid.2=0x2A03
    uno.pid.2=0x0043
    uno.vid.3=0x2341
    uno.pid.3=0x0243
    uno.upload_port.0.vid=0x2341
    uno.upload_port.0.pid=0x0043
    uno.upload_port.1.vid=0x2341
    uno.upload_port.1.pid=0x0001
    uno.upload_port.2.vid=0x2A03
    uno.upload_port.2.pid=0x0043
    uno.upload_port.3.vid=0x2341
    uno.upload_port.3.pid=0x0243
    uno.upload_port.4.board=uno
    
    uno.upload.tool=avrdude
    uno.upload.tool.default=avrdude
    uno.upload.tool.network=arduino_ota
    uno.upload.protocol=arduino
    uno.upload.maximum_size=32256
    uno.upload.maximum_data_size=2048
    uno.upload.speed=115200
    
    uno.bootloader.tool=avrdude
    uno.bootloader.tool.default=avrdude
    uno.bootloader.low_fuses=0xFF
    uno.bootloader.high_fuses=0xDE
    uno.bootloader.extended_fuses=0xFD
    uno.bootloader.unlock_bits=0x3F
    uno.bootloader.lock_bits=0x0F
    uno.bootloader.file=optiboot/optiboot_atmega328.hex
    
    uno.build.mcu=atmega328p
    uno.build.f_cpu=16000000L
    uno.build.board=AVR_UNO
    uno.build.core=arduino
    uno.build.variant=standard
    
    ##############################################################
    

    I want to store this information to make searches.
    Examples:

    • given a vid = 0x2341 and a pid = 0x0243 which board(s) fit(s) ?
    • which is the upload speed for the board named "Leonardo" ?

    I'm not asking you to code for me, I'm just asking for some hints about the best approach: how to parse the document, how to store the information, etc...

    Any idea is appreciated.

    P 1 Reply Last reply 31 Mar 2022, 12:56
    0
    • M Mark81
      31 Mar 2022, 12:52

      Here a sample of the Arduino boards.txt file:

      ##############################################################
      
      yun.name=Arduino Yún
      yun.upload.via_ssh=true
      
      yun.vid.0=0x2341
      yun.pid.0=0x0041
      yun.vid.1=0x2341
      yun.pid.1=0x8041
      yun.vid.2=0x2A03
      yun.pid.2=0x0041
      yun.vid.3=0x2A03
      yun.pid.3=0x8041
      yun.upload_port.0.vid=0x2341
      yun.upload_port.0.pid=0x0041
      yun.upload_port.1.vid=0x2341
      yun.upload_port.1.pid=0x8041
      yun.upload_port.2.vid=0x2A03
      yun.upload_port.2.pid=0x0041
      yun.upload_port.3.vid=0x2A03
      yun.upload_port.3.pid=0x8041
      yun.upload_port.4.board=yun
      
      yun.upload.tool=avrdude
      yun.upload.tool.default=avrdude
      yun.upload.tool.network=arduino_ota
      yun.upload.protocol=avr109
      yun.upload.maximum_size=28672
      yun.upload.maximum_data_size=2560
      yun.upload.speed=57600
      yun.upload.disable_flushing=true
      yun.upload.use_1200bps_touch=true
      yun.upload.wait_for_upload_port=true
      
      yun.bootloader.tool=avrdude
      yun.bootloader.tool.default=avrdude
      yun.bootloader.low_fuses=0xff
      yun.bootloader.high_fuses=0xd8
      yun.bootloader.extended_fuses=0xfb
      yun.bootloader.file=caterina/Caterina-Yun.hex
      yun.bootloader.noblink=caterina/Caterina-Yun-noblink.hex
      yun.bootloader.unlock_bits=0x3F
      yun.bootloader.lock_bits=0x2F
      
      yun.build.mcu=atmega32u4
      yun.build.f_cpu=16000000L
      yun.build.vid=0x2341
      yun.build.pid=0x8041
      yun.build.usb_product="Arduino Yun"
      yun.build.board=AVR_YUN
      yun.build.core=arduino
      yun.build.variant=yun
      yun.build.extra_flags={build.usb_flags}
      
      ##############################################################
      
      uno.name=Arduino Uno
      
      uno.vid.0=0x2341
      uno.pid.0=0x0043
      uno.vid.1=0x2341
      uno.pid.1=0x0001
      uno.vid.2=0x2A03
      uno.pid.2=0x0043
      uno.vid.3=0x2341
      uno.pid.3=0x0243
      uno.upload_port.0.vid=0x2341
      uno.upload_port.0.pid=0x0043
      uno.upload_port.1.vid=0x2341
      uno.upload_port.1.pid=0x0001
      uno.upload_port.2.vid=0x2A03
      uno.upload_port.2.pid=0x0043
      uno.upload_port.3.vid=0x2341
      uno.upload_port.3.pid=0x0243
      uno.upload_port.4.board=uno
      
      uno.upload.tool=avrdude
      uno.upload.tool.default=avrdude
      uno.upload.tool.network=arduino_ota
      uno.upload.protocol=arduino
      uno.upload.maximum_size=32256
      uno.upload.maximum_data_size=2048
      uno.upload.speed=115200
      
      uno.bootloader.tool=avrdude
      uno.bootloader.tool.default=avrdude
      uno.bootloader.low_fuses=0xFF
      uno.bootloader.high_fuses=0xDE
      uno.bootloader.extended_fuses=0xFD
      uno.bootloader.unlock_bits=0x3F
      uno.bootloader.lock_bits=0x0F
      uno.bootloader.file=optiboot/optiboot_atmega328.hex
      
      uno.build.mcu=atmega328p
      uno.build.f_cpu=16000000L
      uno.build.board=AVR_UNO
      uno.build.core=arduino
      uno.build.variant=standard
      
      ##############################################################
      

      I want to store this information to make searches.
      Examples:

      • given a vid = 0x2341 and a pid = 0x0243 which board(s) fit(s) ?
      • which is the upload speed for the board named "Leonardo" ?

      I'm not asking you to code for me, I'm just asking for some hints about the best approach: how to parse the document, how to store the information, etc...

      Any idea is appreciated.

      P Offline
      P Offline
      Pl45m4
      wrote on 31 Mar 2022, 12:56 last edited by Pl45m4
      #2

      @Mark81 said in Best way to parse Arduino boards.txt:

      I'm just asking for some hints about the best approach: how to parse the document, how to store the information, etc...

      Create this as QFile, read every line and split the substrings by =.
      Then you have some sort of Key <-> Value pairs.

      • https://doc.qt.io/qt-5/qfile.html#using-streams-to-read-files

      Edit:

      To improve it even more, you could create a struct or class, which includes all settings from your config file(s). Then you can easily compare Arduino_X.name with Arduino_Y.name and any other settings.


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 31 Mar 2022, 18:41 last edited by
        #3

        Hi,

        If you need to manage complex queries, you could also store that data in a SQLite database using the Qt SQL module.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mark81
          wrote on 1 Apr 2022, 05:55 last edited by
          #4

          Thank you guys,
          of course I'm able to do what you said manually.

          I was wondering if there were any smart approach to automate the process, i.e. deducing the schema and mapping the data automatically. For example, using a generic map ("name", "value") instead of the specific names, in order to append all the fields (even the optional ones not present in all boards).

          If there is not such a way I'm going to create a data struct manually (I have to retrieve all the optional fields) as usual.

          P 1 Reply Last reply 1 Apr 2022, 10:31
          0
          • M Mark81
            1 Apr 2022, 05:55

            Thank you guys,
            of course I'm able to do what you said manually.

            I was wondering if there were any smart approach to automate the process, i.e. deducing the schema and mapping the data automatically. For example, using a generic map ("name", "value") instead of the specific names, in order to append all the fields (even the optional ones not present in all boards).

            If there is not such a way I'm going to create a data struct manually (I have to retrieve all the optional fields) as usual.

            P Offline
            P Offline
            Pl45m4
            wrote on 1 Apr 2022, 10:31 last edited by Pl45m4 4 Jan 2022, 10:31
            #5

            @Mark81

            If you read line by line and add all substrings as key or value, as I've said, it stays dynamic and you can add as much lines as you want. Whether you create a structure or not is up to you :)

            And even in a struct you could have something like "Additional information" where you put device specific stuff or options, which are not included in every "board"


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            1 Reply Last reply
            0

            1/5

            31 Mar 2022, 12:52

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved