Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Ryan Truer
    @rtrue983
    headers will be variable, can i rescale the limit to guarantee 1k data each time
    we are using an archaic uart protocol that uses 1k chunks
    Ryan Truer
    @rtrue983
    ?
    Deomid Ryabkov
    @rojer
    recv_mbuf_limit applies to the entire buffer, so no, unfortunately
    Jim Rhodes
    @jimjiminyjimjam_twitter
    Just looking at wrapping json_fread with ffi so i can call it from JS - it says the caller must free() - how do i go about doing this if the caller is with MJS?
    Deomid Ryabkov
    @rojer
    There's Sys.free
    Jim Rhodes
    @jimjiminyjimjam_twitter
    I can just call that after the FFI'd function?
    Deomid Ryabkov
    @rojer
    yes, i think so
    Jim Rhodes
    @jimjiminyjimjam_twitter
    great thanks - I'll give it a try
    Jim Rhodes
    @jimjiminyjimjam_twitter
    Struggling a little with making an FFI'd function work. Here's my C function:
    char *file_read(const char *fn){
      char *json;
    
      if (!(json = json_fread(fn))) {
        LOG(LL_ERROR, ("%s: Could not json_fread()", fn));
        return NULL;
      }
      return json;
    }
    that compiles fine
    then in JS I've got:
    let readFile = ffi('char *file_read(const char *)');
    Deomid Ryabkov
    @rojer
    ffi doesn't know const, drop it form the argument
    Jim Rhodes
    @jimjiminyjimjam_twitter
    ah ok - I thought it might be my C letting me down
    But otherwise I'm going about it the right way?
    Deomid Ryabkov
    @rojer
    yep
    André Carvalhais
    @carvalhais
    I probably should learn some JS too. Faster to prototype applications...
    Deomid Ryabkov
    @rojer
    well, maybe ECMA JS is, but personally, i'm not a fan of mJS
    André Carvalhais
    @carvalhais
    Would you mind pointing out the reasons why?
    Deomid Ryabkov
    @rojer
    c is ok except for memory management and strings, and actually, c++ solves that
    because it's "JS but not JS". things you read online for js don't work, some really basic stuff is missing.
    André Carvalhais
    @carvalhais
    Hmmm
    Deomid Ryabkov
    @rojer
    JS supposedly frees you from emmory management but mJS is so closely coupled with C that it's no always the case
    there should be no Sys.free, and yet there is :)
    i'm telling you, C++11 with RAII, stdlib for things like strings and maps and lambdas for async programming (which mos requires), is the bee's knees :)
    proper classes for modeling things in the app, too. downside: memory consumption. but that's prototyping. and honestly, you may end up not even caring - it may just turn out fine.
    André Carvalhais
    @carvalhais
    I should learn some c++ then. On the plus side of that I already have some experience with c
    Deomid Ryabkov
    @rojer
    yes, definitely pick up some c++.
    of course, Go is the ultimate modern system language. beats everything else to a pulp. speed of execution and development is just unmatched.
    and if TinyGo takes off, then maybe, just maybe... if i had more time, id' work on porting TinyGo to mos
    Go if you can, C++ if you have to, C if you can't help it, Python for quick scripting - that's my recipe.
    and avoid javascript like a plague :)
    André Carvalhais
    @carvalhais
    Yeah, I have a little experience with python too, and like it a lot. But good to get some advice, I'll probably go for some c++ first, since most of the things I do are for deeply embedded stuff. ESP8266 is a luxury device for my standards, but my best bet since I need wifi connectivity.
    But I plan on upgrading my skills to more capable devices like some coter-m4's or whatever
    Deomid Ryabkov
    @rojer
    esp32 is the next logical step up from 8266
    but you can do c++ on esp8266 too.
    André Carvalhais
    @carvalhais
    Yeah, Tensilica made a smart move of openning the esp32 sdk
    Yeah, I know, but what I meant is that I'm usually used to 8 and 16 bit micros
    I'm having a hard time with the event driven model MGOS uses. It took me a while to take off, but now I believe I've identified my main events
    Deomid Ryabkov
    @rojer
    i used to do some pic12x assembly stuff, but only as a hobby
    André Carvalhais
    @carvalhais
    Would you recommend any reading on event-driven programming, that fits well with the MGOS model?
    Deomid Ryabkov
    @rojer
    um... existing code? i'm not a books guy myself, i learn things by example
    André Carvalhais
    @carvalhais
    Okay, thanks for the tips nevertheless
    Deomid Ryabkov
    @rojer
    you are welcome
    Manfred Müller-Späth
    @mamuesp
    @rojer - I don't quite agree with your judgment. On the one hand I prefer Perl for the fast script, Python I "hate" since the end of the 1990's (indentation depth as syntax component is a no-go for me), and if you have internalized the prototyping concept of JavaScript, this is a very flexible language. Ok, in mJS only a part is represented, and that you need "Sys.free" is more due to the engine than to the language. Nevertheless, mJS is unmatched for prototyping. I use it and then convert the time and memory-critical parts into C. Being able to test functionalities without flashing is an invaluable advantage.
    On the other hand, TinyGo sounds interesting for MOS. And as far as C++ is concerned - there is no HowTo on how to deal with MOS. If there was a simple example program without much specific code that one could analyze, I would offer to write one.
    Pim van Pelt
    @pimvanpelt
    I think the purpose of mongoose os is not (should not be) to learn people how to write C++ or Javascript or C or Go
    If a reader is unfamiliar with C++, I suggest they grab one of the many references on how to learn it
    there's nothing special at all about Mongoose OS wrt C++ semantics
    Manfred Müller-Späth
    @mamuesp
    @pimvanpelt - Are you referring to my statement? If so, then my hint was only to see how to integrate C++ files and if and when C wrapers are necessary. This question is posed here quite often ...
    Pim van Pelt
    @pimvanpelt
    The question is posed by people who don't have a good command of the languages and differences between them