ruudverheijden/node-p1-reader

Serial port from config

Closed this issue · 8 comments

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.

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?

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.

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

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.

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.

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.

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? ;)

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