Using node module that requires nodes serial module

Posted on
  • Noob question;

    I wan to use this library: https://www.npmjs.com/package/modbus-rtu­

    It uses a Serial library that is for node. Will that conflict with the Espurino serial? Would I just pass in an instance of the Espruino Serial connection when creating the Modbus master?

  • You would pass in an instance of the Espruino Serial instead of using the node serial library - the node serial behavior looks very similar to Espruino's API, so you may be okay just using it other than that - or there may be tweaks needed to make it work.

  • You'd need to copy the module locally in case there were any changes you needed (and because the Web IDE can only automatically pull in single file modules), but looking at the main code it pulls in 6 other modules in order to do what's actually a really trivial job.

    You might find that even if you do get it running it uses up all the available memory (It using lodash definitely won't help).

    So I'd say it'd be easier (and definitely better with Espruino) to just use that module as a base, but to re-write the code to use Uint8Array or even strings. It's only a handful of functions...

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Using node module that requires nodes serial module

Posted by Avatar for jakedempsey @jakedempsey

Actions