Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Michael Kellner
    @mkellner
    @LokiMetaSmith - ignore the above. We found a better solution. With the change (and your branch), I was able to build and run "helloworld" connecting to xsbug with the esp32c3. I was also able to run some wifi examples.
    The change was pushed to Moddable-OpenSource this morning.
    Lawrence R Kincheloe
    @LokiMetaSmith
    o, my! ok, I updated the latest branch, created yet another new branch, merged the changes in debug into it and yes I do seem to have a working HelloWorld!
    alright, it probably needs a lot more testing, but it's looking promising! I'll now port the custom board I built and keep on keeping on.
    Peter Hoddie
    @phoddie
    🎉🎉🎉
    Michael Kellner
    @mkellner
    That's great to hear!
    Chris
    @cmidgley

    The Modules module currently does not work with preload. Is it possible (and not difficult) to enable Modules to work at preload and locate all modules (using host) and use Modules.importNow to import them (which would then pull them into preload)? Basically a runtime way to define preload.

    The problem I'm trying to solve for isn't so much the runtime control over preload (though I thought that was potentially an elegant solution to multiple problems), but that with preload I've lost the ability to know the name of the module that is being loaded when module-scope code executes (before, I could locate a unit test module using Modules.host, track it's module name, and importNow which would cause the Jest module scope code to execute and register tests mapped to the module name). Now, understandably, modules load outside of my runtime control and therefore all module-scope code executes without any ability to track the module that is executing.

    Peter Hoddie
    @phoddie
    Preload loads JavaScript modules during the build. Therefore, the modules run on your computer, not the target device. Consequently, they cannot call host functions because those may be written for a different instruction set, may be written for a different operating system, and and may depend on hardware resources or APIs that are not present. That's why not all modules may be preloaded. The Modules module is one of those.
    Peter Hoddie
    @phoddie
    So, the Modules module is not an option here. The only native code that runs is XS built-ins, of course, since XS can guarantee that it provides the same functions at build time and execution time. Dynamic import isn't an option because it is asynchronous and modules loaded at preload are synchronous. It might be possible to use importNow on a Compartment instance to synchronously load a module during preload. I don't have time to try it this morning.
    Chris
    @cmidgley
    No worries - don't take any more time on this. Just thought I'd check. I just got a workaround - a bit ugly but seems to work fine.
    Peter Hoddie
    @phoddie
    @cmidgley – here's a bit of trivia for future reference. You asked about how to run code after preload completes. It turns out there's a simple solution: use a Promise:
    Promise.resolve().then(() => {
        // this code runs after all preloads complete but before lockdown of the firmware image
    });
    Chris
    @cmidgley
    Interesting! I'll give it a try (though I have found a workaround that is working ... using the last entry in the preload array as you suggested). This might simplify the manifests though so I'll give it a whirl. thx.
    Lawrence R Kincheloe
    @LokiMetaSmith
    there's a typo, #define ICACHE_XS6RO2_ATTR attribute((section(".rodata.xs6ro2"))) attribute((aligned(4)))
    #define ICACHE_XS6STRING_ATTR __attribute((section(".rodata.str1.4"))) __attribute__((aligned(4)))

    it was listed as

    define ICACHE_XS6STRING_ATTR attribute((section(".rodata.str1.4"))) attribute__((aligned(4)))

    but should be

    define ICACHE_XS6STRING_ATTR attribute((section(".rodata.str1.4"))) attribute((aligned(4)))

    still doesn't fix the issue though

    I gotta figure out formatting in gitter, this is horrible...
    Peter Hoddie
    @phoddie
    Good catch. GCC attributes like that are really difficult to read (and apparently to write reliably too!).
    What's the issue you are looking into?
    Lawrence R Kincheloe
    @LokiMetaSmith
    trying to stage the esp32c3 pull request
    but there's code I commented out to make it work, and figuring out why it isn't working is well, entertaining
    Peter Hoddie
    @phoddie
    Could be. The section stuff with GCC has always been a little mysterious. The section attributes are necessary on ESP8266 but I think on ESP32 they aren't really necessary (different versions of GCC, different CPU capabilities). The attribute is still relevant. Maybe you can eliminate the section attribute for your target (maybe we can do that for ESP32 in general?).
    moddable getting love during jsconf budapest from nick!
    Peter Hoddie
    @phoddie
    That looks so great! Thanks for posting. I'm going to have to make time to watch that today.
    Lawrence R Kincheloe
    @LokiMetaSmith
    heads up, esp-idf version 5 has a bunch of migration issues. https://docs.espressif.com/projects/esp-idf/en/latest/esp32/migration-guides/index.html
    Peter Hoddie
    @phoddie
    No doubt! Every major version does. We've survived all the other transitions. We'll get through this one too.
    Peter Hoddie
    @phoddie
    (I just hope audio isn't broken again. Or, at least, that v5 finally correctly fixes the ADC audio woes of ESP-IDF v4.4. @meganetaaan and I have wrestled with that enough.)
    Lawrence R Kincheloe
    @LokiMetaSmith

    I'm still getting error: conflicting types for 'size_t' typedef __SIZE_TYPE__ size_t;
    feeling kind of stuck.

    https://github.com/juniper-garden/moddable/tree/testing_tag3

    Peter Hoddie
    @phoddie
    Will try to take a look today.
    Michael Kellner
    @mkellner
    @lokimetasmith, using your testing_tag3 branch... at line 112 in xs/includes/xs.h change from #if defined(__ets__) to #if defined(__ets__) && !ESP32. And in xs/platforms/esp/xsHost.h, change the vPortEnter/ExitCritical to portENTER_/portEXIT_CRITICAL to get past the next hurdle.
    Michael Kellner
    @mkellner
    Thanks to @LokiMetaSmith, there is now early support for the esp32c3.
    Michael Kellner
    @mkellner
    There are a number of c3 boards out there. I have been using the ESP32-C3-DevKitM-1 from Espressif. For the AI Thinker modules like ESP-C3_32S-Kit or ESP-C3-12F-Kit, I had to set UPLOAD_SPEED to 460800.
    Lawrence R Kincheloe
    @LokiMetaSmith
    They both use the CH340 serial chipset, which I think should set the max baud rate, also the layout if mismatched impedance on the data lines cause any issues. The ESP32c3 devkit m1 uses CP2102N-A02-GQFN28
    Lawrence R Kincheloe
    @LokiMetaSmith
    yeah, from the datasheet" For one-directional 1Mbps and above, or bi-directional 500Kbps and above, recommended to use CH343,
    enable automatic hardware flow control.
    The baud rate error of CH340 UART reception is about 2%, the baud rate error of CH340G/CH340T/CH340R
    UART transmission is less than 0.3%, and the baud rate of CH340C/CH340N/CH340K/CH340E/CH340X/CH340B
    is less than 1.2%"
    I bet you're dealing with a lower grade CH340
    mtoko
    @mtoko
    Hi, I have just bought the IOT Development book and am working my way through it. I did eventually get the toolchain setup and am working on Chapter 3 networking. I am using an ESP8266 and have tested all the connect to Wifi examples and these work fine, I want to continue to the http-get example, but it not too clear how to use this. I assume that the esp needs to be connected to Wifi first so I have added the http-get code to the main.js in wifi-code, but the I get an error in the debugger (host): module "http" not found. If I can work this out it will help with the rest of the examples. Any advice appreciated
    Andy Carle
    @PrototypingAndy_twitter

    Hi @mtoko, welcome to our Gitter! Most of the Chapter 3 examples use a two-step process: first you install the host application and then you use mcrun to install the example mods. Have you worked through any of the examples that work this way in earlier chapters? If not, it may be worth briefly going back to Chapter 1 to familiarize yourself with the process.

    I'm guessing that we're not in the same time zone, so I'll provide some additional instructions here to keep you moving if you return to this while I'm offline. Basically, you want to go to the ch3-network folder in your terminal and then do something like:

    cd host
    mcconfig -d -m -p esp

    then when the host app has successfully launched, use control-c to break out of the debugger connection, then do:

    cd ..
    cd http-get
    mcrun -d -m -p esp
    mtoko
    @mtoko
    Hi @PrototypingAndy_twitter , thanks for the help! I have made great progress and got the examples running on both esp and esp32. The setting up of the toolchain was a challenge but the detailed description on Github and the instructions in the book are excellent. I would have been interested in this anyway but I am a long time Node Red user and have seen the early implementation of Node Red on esp. I have got the MQTT example running, the possibilities of this boggle the mind! Who would have thought in these times that buying a book would be so worthwhile!
    Andy Carle
    @PrototypingAndy_twitter
    Great! I'm glad to hear that you got it working.
    js4iot
    @js4iot
    Does Moddable have a way to connect to a gRPC server talking over HTTP/2?
    Peter Hoddie
    @phoddie
    Hey, @js4iot. We don't currently support HTTP/2. That would be a bit of an adventure.
    Why do you ask?
    js4iot
    @js4iot
    Totally understood. I asked because the company that I work for (Salesforce) released a new product to broadcast messages based on gRPC (http/2) and I was thinking on building a demo. I guess I could have some middleware where I connect from the board using MQTT, and from Salesforce using the new product. Thanks
    Peter Hoddie
    @phoddie
    Thanks for the info. A bridge between gRPC (HTTP/2) and MQTT (or WebSockets?) sounds like a practical place to start.
    Tobias Wendling
    @tobiaswendling

    Hello everyone! I got some problems with my project:
    manifest.json

    {
        "include": [
            "$(MODDABLE)/modules/io/manifest.json",
            "$(MODDABLE)/modules/drivers/sensors/ccs811/manifest.json",
            "$(MODDABLE)/modules/drivers/sensors/bmp280/manifest.json",
            "$(MODDABLE)/modules/drivers/sensors/shtc3/manifest.json"
        ],
        "modules": {
            "*": [
                "./main"
            ]
        }
    }

    main.js

    import CCS811 from "embedded:sensor/AirQuality/CCS811"
    import BMP280 from "embedded:sensor/AtmosphericPressure-Temperature/BMP280"
    import SHTC3 from "embedded:sensor/Humidity-Temperature/SHTC3";
    import Timer from "timer"
    
    const bmp280 = new BMP280({ 
        sensor: device.I2C.default 
    })
    
    const ccs811 = new CCS811({ 
        sensor: {
            ...device.I2C.default,
            io: device.io.SMBus
        }
    })
    
    const shtc3 = new SHTC3({ 
        sensor: device.I2C.default 
    })
    
    bmp280.configure({ 
        mode: 3,
        temperatureSampling: 2,
        pressureSampling: 5,
        filter: 4,
        standbyDuration: 4
    })
    
    ccs811.configure({ mode: 1 })
    
    shtc3.configure({
        lowPower: false,
        autoSleep: false
    });
    
    Timer.repeat(() => {
        const bmp280_sample = bmp280.sample()
        const ccs811_sample = ccs811.sample()
        const shtc3_sample = shtc3.sample()
    
        const temperature = bmp280_sample.thermometer.temperature?.toFixed(2)
        const pressure = bmp280_sample.barometer.pressure?.toFixed(2)
        const eco2 = ccs811_sample.eCO2
        const tvoc = ccs811_sample.TVOC
        const humidity = shtc3_sample.hygrometer.humidity?.toFixed(2)
    
        trace(`Temperature: ${ temperature } C\n`)
        trace(`Pressure: ${ pressure } C\n`)
        trace(`eCO2: ${ eco2 } ppm\n`)
        trace(`TVOC: ${ tvoc } ppm\n`)
        trace(`Humidity: ${ humidity } %RH\n`)
    }, 2000)

    When i execute my code with mcconfig -d -m -p esp32/nodemcu xsbug starts but it looks like that the main.js tab is flickering - if i click on it it instantly closes. Looks like its stuck in a loop. What can i do?

    Tobias Wendling
    @tobiaswendling
    The problem also occurs when opening another project (e.g. moddable/examples/drivers/sensors/bmp280
    Michael Kellner
    @mkellner

    Hello @tobiaswendling. I tried your code on a nodemcu without any sensors connected. If you put a line debugger; after the imports, then you can step through the creation of your sensor objects and see which one fails.

    I then connected up the set of sensors (SHTC3, CCS811 and BMP180) and tried again and... Success!

    Humidity: 38.74 %RH
    Temperature: 27.18 C
    Pressure: 100872.29 C
    eCO2: 410 ppm
    TVOC: 1 ppm
    So, I suspect a wiring issue.
    Tobias Wendling
    @tobiaswendling
    Ok, i'll check that again - thanks for the reply!