ruudverheijden / node-p1-reader

Node.js package for reading and parsing data from the P1 port of a Dutch or Belgian Smart Meter.
MIT License
25 stars 25 forks source link

Serial port from config #1

Closed ErwinSteffens closed 7 years ago

ErwinSteffens commented 7 years ago

Great library!

Any interest on picking the serial port from the config instead of using the auto discovery?

I've the P1 reader connected to an /dev/ttyUSB0 which is not listed in the discovered ports on position 0, so I'm not able to use the lib.

ruudverheijden commented 7 years ago

Thanks!

Sure it's possible to add the option to force a certain port. However, I first would like to have a look at fixing the port auto discover function as it should work. Can you send me the console log you get when starting the module?

ErwinSteffens commented 7 years ago

It starts with opening /dev/ttyAMA0, but there is not data coming and also no error is raised, so it does not start trying the next port.

Maybe it is a good idea to also expose the package parsing lib, just if you only want this functionality.

ruudverheijden commented 7 years ago

I will have a look at it and try to fix it

ErwinSteffens commented 7 years ago

Ok, thanks, but I still would like an option to configure the port myself. This would be my preferred usage of the lib. I have the serial port from config or command line arguments.

I can suggest an PR for this if you want.

ruudverheijden commented 7 years ago

Sure I agree! I think the best way of forcing a port would be by passing the port as an option when initiating the module. So you have to control of setting the port from you own application. I've added the functionality to github but I'm unable to test it at the moment since. Will try to test it during the weekend. After its tested I will push it to NPM.

ErwinSteffens commented 7 years ago

Ok, great. For now I've included the files in my own project to make some progress. This is my script for now: https://gist.github.com/ErwinSteffens/bf03e3dbc34273d2a028ef8fdf5076ab, but it is better if it is included in your lib.

ruudverheijden commented 7 years ago

I've tested it and it seems to work fine in my case. Version 1.1.0 is now published to NPM.

Can you please verify if it's working for you as well? ;)

ErwinSteffens commented 7 years ago

Ok, thnx, I will try to test it this weekend.