Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    btree lib support

    Scheduled Pinned Locked Moved MicroPython
    micorpythonmodules
    19 Posts 6 Posters 1.8k Views 5 Watching
    Loading More Posts
    • 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.
    • I Offline
      InverseEffect
      last edited by

      I was looking for a very lightweight database-like (key-value pair) storage mechanism for micropython and stumbled across the btree micropython library but it is not included in Pycom's FW build. Is it easy to add, I cannot find single btree.py file which makes me think it is heavily dependent on C or something. I need a way to store records of RFID tags for example and then look it up as tag 'swipes' are detected. I cannot store this info in the cloud as the latency will be too high. Any ideas?
      Also found that calling

      help('modules')
      

      returns:

      object modules is of type str
        encode -- <function>
        find -- <function>
        rfind -- <function>
        index -- <function>
      ....
      ....
      

      This help command is suppose to list all the installed python modules?

      Thanks

      robert-hhR L 3 Replies Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @InverseEffect
        last edited by

        @inverseeffect The code for the btree moddule is in the repository, but not enabled in the standard build. You can do that, but you have to set up the build environment for that, add to esp32/mpconfigport.h the line

        #define MICROPY_PY_BTREE (1)

        and then build your target. I must confirm that I did not try that, so I'm not sure if it build w/o errors. But there is a good chance that it does. I can try this night.

        A 1 Reply Last reply Reply Quote 1
        • L Offline
          livius @InverseEffect
          last edited by livius

          @inverseeffect
          Do you really need btree? You say about key value pair. Dictionary is enough for that.
          Or do you really need some benefits from btree?

          think about people first, then computers

          I 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @InverseEffect
            last edited by

            @inverseeffect Including BTREE is not as easy as I assumed. All components are there, but the make files have to be aligned too.

            1 Reply Last reply Reply Quote 0
            • I Offline
              InverseEffect @livius
              last edited by

              @livius I don't necessarily need btree. Any memory efficient key-value pair will do. I thought about saving a dictionary to file via json but the issue is that depending on the number of elements, it might use up a lot of ram to read the whole file to json then to dictionary. I guess I can come up with a file scheme by saving certain ranges in seperate files.

              1 Reply Last reply Reply Quote 0
              • FridaF Offline
                Frida
                last edited by

                Can nvram be used?

                I 1 Reply Last reply Reply Quote 0
                • I Offline
                  InverseEffect
                  last edited by

                  @robert-hh thanks for trying though. I must still learn about make files and all that cross compiling stuff. I'm used to IDEs that hide all that complexity from me :)

                  1 Reply Last reply Reply Quote 0
                  • I Offline
                    InverseEffect @Frida
                    last edited by

                    @frida If jou are referring to Pycom's nvram key-value pair then no because it can only store a single 32bit int as the value. I want to save more information.

                    1 Reply Last reply Reply Quote 0
                    • A Offline
                      ASH247iT @robert-hh
                      last edited by

                      @robert-hh I realise this is an old post - did you manage to prove BTree was available? If so could you give some more details how I might get it. Im a bit of a newbie to both Pycom and python ! Thanks

                      robert-hhR 1 Reply Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @ASH247iT
                        last edited by

                        @ASH247iT No change. The source files are present, but are not included in the build.

                        A 1 Reply Last reply Reply Quote 0
                        • A Offline
                          ASH247iT @robert-hh
                          last edited by ASH247iT

                          @robert-hh Could it not be made available as a .mpy file so I could just drop it into a project or are there some simple instructions for compiling / flashing etc ?
                          is this the file you refer to above?
                          https://github.com/micropython/micropython/blob/master/ports/esp32/mpconfigport.h

                          robert-hhR 1 Reply Last reply Reply Quote 0
                          • robert-hhR Offline
                            robert-hh @ASH247iT
                            last edited by robert-hh

                            @ASH247iT Btree is C-Code, not compiled Python code. mpconfigport.h is surely one place to change, but also application.mk, and others.
                            The Micropython.org branch has all the details, and that has to be replicated to the Python branch. Just setting MICROPY_PY_BTREE = 1 is not sufficient.

                            A 1 Reply Last reply Reply Quote 0
                            • A Offline
                              ASH247iT @robert-hh
                              last edited by ASH247iT

                              @robert-hh So not easy then ? Unless you know what you're doing !!
                              Looking on the ESP32 Expressif forum (fairly old post)
                              https://www.esp32.com/viewtopic.php?f=17&t=2446
                              It mentions something about a menuconfig - "Btree module is included, can be Enabled/Disabled via menuconfig." - is this applicable to a Pycom wipy or will this not work? (sorry if this is a stupid question - as I said Im a newbie)

                              A robert-hhR 2 Replies Last reply Reply Quote 0
                              • A Offline
                                ASH247iT @ASH247iT
                                last edited by

                                @robert-hh Do you know if there is a step by step official document for doing this with the WiPy please? Thanks Adrian

                                1 Reply Last reply Reply Quote 0
                                • robert-hhR Offline
                                  robert-hh @ASH247iT
                                  last edited by

                                  @ASH247iT The espressif ESP32 Btree module will be different to the MicroPython Btree module. Even if you configure it into the image - which is the easier part- the Python API is missing, and access to the file system is also not given.
                                  I tried to port in the MicroPython variant, but gave up when it requested the vfsposix module in addition.
                                  So one option for you would be to use the MicroPython.org firmware for ESP32, if Btree is really essential for you. That should run on a WiPy3. Obviously this causes some inconvenience, like the GPIO numbers are not Pxx but the raw Chip numbers. And the Pycom infrastructure is missing, like PyBytes. Some modules are missing too, like ftp and telnet. FTP can be provided by a Python variant.

                                  A 1 Reply Last reply Reply Quote 1
                                  • A Offline
                                    ASH247iT @robert-hh
                                    last edited by

                                    @robert-hh Many Thanks

                                    robert-hhR 1 Reply Last reply Reply Quote 0
                                    • robert-hhR Offline
                                      robert-hh @ASH247iT
                                      last edited by

                                      @ASH247iT I have created a branch of the pycom repository which includes btree. It is here:
                                      https://github.com/robert-hh/pycom-micropython-sigfox/tree/berkeley-db
                                      I can also provide you a firmware tarball for testing, if you tell me the Pycom module you are using (WIPY, FIPY, ...).

                                      F 1 Reply Last reply Reply Quote 2
                                      • F Offline
                                        Fakstory @robert-hh
                                        last edited by

                                        @robert-hh I am looking exactly for something like that. The "firmware tarball" you're talking about, is it the firmware file needed to flash the pycom (gpy) device? using pycom-fwtools?
                                        If so, I would really like a firmware tarball for the gpy (for testing)!
                                        I'll consider building it later.

                                        Thanks in advance!
                                        Fak

                                        robert-hhR 1 Reply Last reply Reply Quote 0
                                        • robert-hhR Offline
                                          robert-hh @Fakstory
                                          last edited by robert-hh

                                          @Fakstory I made a tarball and placed it here: https://github.com/robert-hh/Shared-Stuff.git
                                          You should be able to load it with the Pycom update tools. I have no GPy here, so I cannot test, whether the firmware works.

                                          1 Reply Last reply Reply Quote 1

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          • 1 / 1
                                          • First post
                                            Last post

                                          Pycom on Twitter

                                          Pycom