Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Importing a Library to Arduino Enquiry

Hi,
I made work SDM energy meter with Arduino and ESP8266 through the library https://github.com/reaper7/SDM_Energy_Meter .
I would like to know how to import this library in order to make it work with Mongoose OS.

Thanks for your help.
Davide

Comments

  • SergeySergey Dublin, Ireland

    Look how other Arduino libraries were ported.

  • Hi,
    I do not a specialist of mongoose Os.
    I have search the example or guide to developed an library custom, but the link in mongoose forum in not active.
    could you please give me some advice about it?

    thanks

  • I've Tried to create a new deps/lib
    In the folder /src and /include like the tutorial I put the mgos_mylib.h and mgos_mylib.c
    after I 've editing the mos.yml with the libs: mylib.

    unfortunatly the build returned this error.

    I've attached the log verbose

    Could you help me please.

    Thanks

  • Error: open /fwbuild-volumes/2.8.1/apps/sdm120/esp8266/build_contexts/build_ctx_728000399/libs/sdm120/mos.yml: no such file or directory
    

    A library needs it's own mos.yml: How to create a new library

    Taking a closer look at the library you want to port, it appears it uses HardwareSerial or SoftwareSerial which are not implemented in arduino-compat
    You will have to port the Arduino code to native Mongoose OS.

  • edited November 21

    Sorry for my little competence, but i dont'understand.

    I've a principal folder name: sdm.

     sdm-
    -.git
    - build
    -deps (download through "mos clone https://github.com/mongoose-os-libs/empty deps/sdm_lib "
    -fs
    -src
    -mos
    -readme
    -license
    

    the folder deps containt :

    - sdm_lib:
                      -.git
                      - build
                      - include (mgos_sdm_lib.h)
                      - src (mgos_sdm_lib.c)
                      - mos (that contain the single line "libs : name sdm_lib)
                      - license
                      - readme
    

    in the second, where e how port the Arduino code to native Mongoose OS.
    Please, you can do some clarity about it?
    sorry me, but I'm trying to create a base to understand how to use mongoose os in esp8266 without always making a copy and paste of what I find around.
    thanks

  • nliviunliviu Romania
    edited November 21

    I think How to create a new library and How to port an Arduino library are pretty clear:

    • sdm/mos.yml: add
    libs:
      - name: sdm_lib
    
    • sdm/sdm_lib/mos.yml: add
    includes:
      - include
    
    libs:
      - origin: https://github.com/mongoose-os-libs/arduino-compat
    

    SDM.h and SDM_Config_User.h should be in sdm/sdm_lib/include and SDM.cpp in sdm/sdm_lib/src

    "port the Arduino code to native Mongoose OS" means to implement what you need using Mongoose OS API and libraries.

  • edited November 21

    I've add the line in sdm/sdm_lib/mos.yml but the error is the same.

    Connecting to https://mongoose.cloud, user test
    Uploading sources (2014 bytes)
    Handling lib "zz_boards"...
    Handling lib "rpc-service-fs"...
    Handling lib "sdm_lib"...
    Handling lib "rpc-uart"...
    Handling lib "core"...
    sdm_lib: Prepared local dir: "/fwbuild-volumes/2.8.1/apps/sdm/esp8266/build_contexts/build_ctx_523425226/libs/sdm_lib"
    Handling lib "ca-bundle"...
    Handling lib "rpc-service-config"...
    Error: open /fwbuild-volumes/2.8.1/apps/sdm/esp8266/build_contexts/build_ctx_523425226/libs/sdm_lib/mos.yml: no such file or directory
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:821: reading manifest "/fwbuild-volumes/2.8.1/apps/sdm/esp8266/build_contexts/build_ctx_523425226/libs/sdm_lib/mos.yml"
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:739: 
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:530: 
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:690: 
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:604: 
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:392: 
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:127: 
    /go/src/cesanta.com/mos/build_local.go:116: 
    /go/src/cesanta.com/mos/build.go:202: 
    /go/src/cesanta.com/mos/build.go:145: 
    /go/src/cesanta.com/mos/main.go:171: build failed
    Error: /go/src/cesanta.com/mos/build_remote.go:281: build failed
    /go/src/cesanta.com/mos/build.go:202: 
    /go/src/cesanta.com/mos/build.go:145: 
    /go/src/cesanta.com/mos/main.go:171: build failed
    exit status 1
    Command completed.
    

    Is correct the file into /sdm/sdm_lib/mgos_sdm_lib.c ?

    #include "mgos_sdm_lib.h"
    //NOTE : library init function must be called mgos_sdm_lib_init()
        bool mgos_sdm_lib_init()    {
            return true;
        }
    
  • The file mgos_sdm_lib.c should be in /sdm/sdm_lib/src

    Ahhh! I've just noticed you use cloud build. For local libraries you should build with the --local flag. Local builds are possible only with Docker installed.

  • azz :-(

    I try to install doker on win10 and see what happens!

  • Is libs-dir the directory where is sdm_lib?
    Is repo the directory where is locate mos.exe ?

    It is the current error :

    mos build --local --arch --esp8266 --libs-dir F:/mos/sdm/deps --repo F:/ --verbose
    Handling lib "rpc-uart"...
    Handling lib "sdm_lib"...
    Handling lib "rpc-service-fs"...
    Handling lib "rpc-service-config"...
    sdm_lib: Prepared local dir: "F:\mos\sdm\deps\sdm_lib"
    Handling lib "core"...
    Error: repository does not exist
    /go/src/cesanta.com/common/go/ourgit/ourgit_gogit.go:218:
    /go/src/cesanta.com/mos/build/swmodule.go:505:
    /go/src/cesanta.com/mos/build/swmodule.go:211:
    /go/src/cesanta.com/mos/build.go:496: core: preparing local copy
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:662:
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:604:
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:392:
    /go/src/cesanta.com/mos/manifest_parser/manifest_parser.go:127:
    /go/src/cesanta.com/mos/build_local.go:116:
    /go/src/cesanta.com/mos/build.go:202:
    /go/src/cesanta.com/mos/build.go:145:
    /go/src/cesanta.com/mos/main.go:171: build failed
    exit status 1
    Command completed.

    thanks

  • mos build --local --platform esp8266 --clean.
    Take care not to delete the deps folder :smile:
    Or move the sdm_lib directory somewhere else and modify the application's mos.yml:

    - origin: <path>/sdm_lib
    

    instead of

    - name: sdm_lib
    
  • I've execute this comand.

    the process abort to the final compiling.
    I've insert manually the file.h neede to work hardwareserial , ecc

    it is the verbose log.

    thanks

Sign In or Register to comment.