Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial port issues? #1

Closed
tagyoureit opened this issue May 13, 2016 · 6 comments
Closed

Serial port issues? #1

tagyoureit opened this issue May 13, 2016 · 6 comments

Comments

@tagyoureit
Copy link

tagyoureit commented May 13, 2016

Hi Michael,
This isn't really an issue with your code, but not sure how to contact you so hope you can help!
I'm trying to use your pool_controller.js as a basis for my own plug-in for the homebridge project. I have a USB->RS485 cable which is at /dev/ttyUSB0. This in on a RasPi3.

I stripped out everything I didn't need just to see if I could get a stream of the serial data. I uncommented the line 271(logger.info(strData)) and the following is my output. It doesn't quite look right. I was expecting to see Hex, and more constant string lengths. Below is a cut/paste of my log. Would you be able to help point me in the right direction? I've tried a number of things (too much detail to list here).

2016-05-13T04:38:19.896Z - info: Opened /dev/ttyUSB0
2016-05-13T04:38:20.600Z - info: undefined 0
2016-05-13T04:38:20.667Z - info: undefined 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2016-05-13T04:38:20.669Z - info: undefined 0 0
2016-05-13T04:38:20.673Z - info: undefined 0
2016-05-13T04:38:20.678Z - info: undefined 223
2016-05-13T04:38:20.681Z - info: undefined 213
2016-05-13T04:38:20.691Z - info: undefined 255
2016-05-13T04:38:20.694Z - info: undefined 127
2016-05-13T04:38:20.698Z - info: undefined 191
2016-05-13T04:38:20.701Z - info: undefined 145
2016-05-13T04:38:20.706Z - info: undefined 255
2016-05-13T04:38:20.709Z - info: undefined 77
2016-05-13T04:38:20.713Z - info: undefined 113
2016-05-13T04:38:22.685Z - info: undefined 0
2016-05-13T04:38:22.693Z - info: undefined 0 0
2016-05-13T04:38:22.695Z - info: undefined 106 214 225 223 251
2016-05-13T04:38:22.699Z - info: undefined 213
2016-05-13T04:38:22.704Z - info: undefined 255 127 255 255 255
2016-05-13T04:38:22.707Z - info: undefined 255
2016-05-13T04:38:22.712Z - info: undefined 249 255 127 247
2016-05-13T04:38:22.714Z - info: undefined 95
2016-05-13T04:38:22.717Z - info: undefined 255 133
2016-05-13T04:38:22.720Z - info: undefined 255 255
2016-05-13T04:38:22.723Z - info: undefined 255 255
2016-05-13T04:38:22.725Z - info: undefined 77
2016-05-13T04:38:22.728Z - info: undefined 229 249
2016-05-13T04:38:22.731Z - info: undefined 0
2016-05-13T04:38:22.943Z - info: undefined 63
2016-05-13T04:38:22.947Z - info: undefined 253
2016-05-13T04:38:22.959Z - info: undefined 0
2016-05-13T04:38:22.974Z - info: undefined 254
2016-05-13T04:38:22.978Z - info: undefined 225
2016-05-13T04:38:22.989Z - info: undefined 255 165 238 59 254 255

If I just try to do a raw dump of the buffer I get gibberish like � � � � � � � � _ _ � � � � � � � � � M � � � w

I know the USB->RS485 is wired correctly because I can see the correct HEX from the command line:

pi@raspberrypi:~/Home-Device-Controller $ od -x < /dev/ttyUSB0
0000000 b200 0000 0000 0000 ff00 ffff ffff ffff
0000020 00ff a5ff 0f0a 0210 161d 000f 0040 0000
0000040 0000 0300 4000 5004 2050 3c00 0039 0400
0000060 0000 597a 0d00 b203 00ff a5ff 6000 0410
0000100 ff01 1902 00ff a5ff 1000 0460 ff01 1902
0000120 00ff a5ff 6000 0610 0a01 2601 00ff a5ff
0000140 1000 0660 0a01 2601 00ff a5ff 6000 0110
0000160 0204 04c4 02e2 ffc6 ff00 00a5 6010 0201
0000200 e204 fe01 00ff a5ff 6100 0410 ff01 1a02
0000220 00ff a5ff 1000 0461 ff01 1a02 00ff a5ff

Thanks in advance!

@tagyoureit
Copy link
Author

This looks to be a node-serialport issue. I opened a case @ node-serialport, but if you have any input it would be appreciated.

@michaelusner
Copy link
Owner

At first glance, the hex dump does look correct and I see the 0xa5 packet header byte.
If you uncomment line 271 (I think), you can see what's being read from the port.

logger.info(strData)

That might help with further debugging.

@tagyoureit
Copy link
Author

Thanks... I have made a lot of progress. I think Winston(?) may have been converting the buffer object -> undefined. If you follow my link, I was also helped on the other thread. Looking forward to publishing the module soon. Thanks for sharing your code! It's very impressive.

@michaelusner
Copy link
Owner

Thank you, you're too kind. :) It was my first venture into node.js. I'm using the Python code on a Rasberry PI to do the same thing. It's easier to wrap my mind around than node's event model.

@tagyoureit
Copy link
Author

Hi Michael,

quick question - what RS485 serial adapter/cable are you using? Did you have any issues writing back to the bus? I'm stumped on why I can read from, but can't write to, the bus. Not sure if it is my system, cable or code. I looked at your code and mine is very similar. If you can post any (full) test code in either Node or Python that I can try, maybe that would be helpful.

Also, I've made a ton of headway (with help) decoding the broadcast messages. Check out my wiki. Most recently, we uncovered how to read the circuit names from the broadcast messages.

thx,
Tag

@michaelusner
Copy link
Owner

Hey there. I'm on vacation right now and won't be back until Friday. I'll
send you the model names of the converter and USB adapter then.
That's great that you're making progress with more decoding. I seem to have
less time for that stuff lately but the python code that Ioaded onto my
raspberry pi has been very reliable.
I'll send more details and check out your wiki when I get back.

Thanks,
Mike

On Jul 24, 2016 10:28 PM, "tagyoureit" notifications@github.com wrote:

Hi Michael,

quick question - what RS485 serial adapter/cable are you using? Did you
have any issues writing back to the bus? I'm stumped on why I can read
from, but can't write to, the bus. Not sure if it is my system, cable or
code. I looked at your code and mine is very similar. If you can post any
(full) test code in either Node or Python that I can try, maybe that would
be helpful.

Also, I've made a ton of headway (with help) decoding the broadcast
messages. Check out my wiki
https://github.com/tagyoureit/nodejs-Pentair/wiki. Most recently, we
uncovered how to read the circuit names from the broadcast messages.

thx,
Tag


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#1 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGHRl-sYpDa2v34tP2w9KcPJoFgbGPfFks5qZC1igaJpZM4IdseB
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants