plcpeople / nodepccc

Library for node.js to communicate with some Allen-Bradley programmable controllers (PLCs)
MIT License
81 stars 24 forks source link

fix wrong behaviour with odd bytelength strings while reading from plc. #7

Closed jledun closed 8 years ago

jledun commented 8 years ago

I had a trouble while reading strings from plc.

When the string length is pair, no problem but when it's odd, the last character of the string is replaced by "\u0000" and another "\u0000" is added. Unfortunatly, I've worked on that bug yesterday, I don't have exemple to show you the problem.

I run nodepccc with node js v5.3.0 on Arch Linux headless server.

After a few tries, I've found that it would be better to always give a pair string length to the function strSwap then simplified the code of this function.

Now, it works as expected.

Signed-off-by: Julien Ledun j.ledun@iosystems.fr

plcpeople commented 8 years ago

Thanks for the pull request. I merged it, but notice that it adds a space at the end of a string that is not there in the PLC. But it works better than before, thank you.