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

Using with MS/TP Router #28

Open
mwitt1337 opened this issue Jul 21, 2020 · 19 comments
Open

Using with MS/TP Router #28

mwitt1337 opened this issue Jul 21, 2020 · 19 comments

Comments

@mwitt1337
Copy link

mwitt1337 commented Jul 21, 2020

Node Version: 10.15.0

Node BACstack Version: 0.2.4

  • Question

Note: Make sure you have read the FAQs
before logging this issue.

Feature Request / Question

I am trying to use node-bacstack with devices behind a MS/TP router. It is unclear to me how to use node-bacstack to accomplish this. The NET and ADR is not obvious or clear to me. I am trying to discover the devices behind device 156 and read/write their properties. I'm new to MS/TP.

Below is the WHOIS return from /examples/read-device.js
image

Device 156 is the MS/TP router that has child devices/properties. The readproperties function included in the /examples/read-devices.js retuned this JSON for device 156
image

A bacnet explorer returned this for device 156
image

Here is code. Mostly unchanged from the example.

read-device.zip

@Apollon77
Copy link
Collaborator

Can you please run your code with debug?

DEBUG=bacnet:* node yourfile.js

And post the log here

@NubeDev
Copy link

NubeDev commented Jul 22, 2020

@mwitt1337
I had the same issue and found there is support for passing in the network number and mac addr.

For me BACnet router details
ip: 192.168.15.137
network num: 3
For me BACnet device details
BACnet device ms/tp mac: 6

Working code example that was tested a few months ago

// different ways to do a who is including a network whoIs
bacnetClient.whoIs();
bacnetClient.whoIs({'net':0xFFFF});
bacnetClient.whoIs({'net':0xFFFF,'interface':'0.0.0.0'});
bacnetClient.whoIs({'net':3});

//  read a point through a router to an MSTP device
bacnetClient.readProperty({address: '192.168.15.137',net:3,adr:[6]} , {type: 1, instance: 1}, 85, (err, value) => {
  console.log('value: ', value);
  console.log('err: ', err);
});

@Apollon77
Copy link
Collaborator

In theory when you use on('iAm') to get discovered devices then the net/adr should be included in the "found device details".

@mwitt1337 please try to send the "whoIs" as above ... and then we can see in the log output if the found evices include the details as needed.

Then we can enhance the docs and example

@mwitt1337
Copy link
Author

mwitt1337 commented Jul 25, 2020

So here are the commands I ran and the debug log output

bacnetClient.whoIs();

sent whoIs 1595634894063
examples/read-device.js:468
Found Device 3001 on {"address":"10.10.0.22","forwardedFrom":null}
examples/read-device.js:490
Found Device 1234 on {"address":"10.10.0.38","forwardedFrom":null}
examples/read-device.js:490
Found Device 9101 on {"address":"10.10.0.47","forwardedFrom":null}
examples/read-device.js:490
Found Device 156 on {"address":"10.10.0.48","forwardedFrom":null}

bacnetClient.whoIs({'net':0xFFFF});

sent whoIs 1595634940669
examples/read-device.js:468
Found Device 3001 on {"address":"10.10.0.22","forwardedFrom":null}
examples/read-device.js:490
Found Device 1234 on {"address":"10.10.0.38","forwardedFrom":null}
examples/read-device.js:490
Found Device 9101 on {"address":"10.10.0.47","forwardedFrom":null}
examples/read-device.js:490
Found Device 156 on {"address":"10.10.0.48","forwardedFrom":null}
examples/read-device.js:490
Found Device 985911 on {"address":"10.10.0.48","forwardedFrom":null}
examples/read-device.js:490
Found Device 862527 on {"address":"10.10.0.48","forwardedFrom":null}
examples/read-device.js:490
Found Device 48871 on {"address":"10.10.0.47","forwardedFrom":null}

bacnetClient.whoIs({'net':0xFFFF,'interface':'10.10.0.48'});

sent whoIs 1595635017212
examples/read-device.js:468
Found Device 3001 on {"address":"10.10.0.22","forwardedFrom":null}
examples/read-device.js:490
Found Device 156 on {"address":"10.10.0.48","forwardedFrom":null}
examples/read-device.js:490
Found Device 1234 on {"address":"10.10.0.38","forwardedFrom":null}
examples/read-device.js:490
Found Device 9101 on {"address":"10.10.0.47","forwardedFrom":null}
examples/read-device.js:490
Found Device 48871 on {"address":"10.10.0.47","forwardedFrom":null}
examples/read-device.js:490
Found Device 985911 on {"address":"10.10.0.48","forwardedFrom":null}
examples/read-device.js:490
Found Device 862527 on {"address":"10.10.0.48","forwardedFrom":null}

bacnetClient.whoIs({'net':3});

sent whoIs 1595635055268

bacnetClient.whoIs({'net':0});

sent whoIs 1595635116749
examples/read-device.js:468
Found Device 3001 on {"address":"10.10.0.22","forwardedFrom":null}
examples/read-device.js:490
Found Device 156 on {"address":"10.10.0.48","forwardedFrom":null}
examples/read-device.js:490
Found Device 9101 on {"address":"10.10.0.47","forwardedFrom":null}
examples/read-device.js:490
Found Device 1234 on {"address":"10.10.0.38","forwardedFrom":null}

Debug isn't as much information as I expected it to. Device 156 is the MS/TP route and I need to access the devices attached to it.

@Apollon77
Copy link
Collaborator

Yes the debug should be waaaaay more. Please try against and use

DEBUG=bacnet* node Myfile.js

Please

@mwitt1337
Copy link
Author

mwitt1337 commented Jul 27, 2020 via email

@Apollon77
Copy link
Collaborator

Just open a shell and "cd" in the relevant directory and run it from there as described above

@mwitt1337
Copy link
Author

mwitt1337 commented Jul 27, 2020 via email

@biancode
Copy link
Collaborator

biancode commented Jul 27, 2020

Hi, read some more here about debug https://github.com/BiancoRoyal/node-red-contrib-modbus/wiki/DEBUG

But with bacnet ;)

Like:

on CMD:

set DEBUG=bacnet*

on PowerShell:

$env:DEBUG = "bacnet*"

@mwitt1337
Copy link
Author

The image from my email response didn't post. Here is the debug output. It really doesn't seem to have much more information. Does DEBUG=bacnet* already include all of the options specified in the link?

image

@Apollon77
Copy link
Collaborator

which way you sent the whois command?

bacnetClient.whoIs({'net':0xFFFF});
bacnetClient.whoIs({'net':0xFFFF,'interface':'0.0.0.0'});
bacnetClient.whoIs({'net':3});

?

@mwitt1337
Copy link
Author

I ran the who is command 4 different ways and attached a text file of the outputs.

net 0.txt
net 0xFFFF.txt
net 3.txt
new 0xFFFF with interface.txt

@NubeDev
Copy link

NubeDev commented Jul 28, 2020

Are you using wireshark to debug?
Have you tried to read a point value or anything different to a whoIs?

Like this

//  read a point through a router to an MSTP device
bacnetClient.readProperty({address: '192.168.15.137',net:3,adr:[6]} , {type: 1, instance: 1}, 85, (err, value) => {
  console.log('value: ', value);
  console.log('err: ', err);
});

@mwitt1337
Copy link
Author

I was able to make some progress on one of the devices.

bacnetClient.on('listening', () => { bacnetClient.readProperty({address: '10.10.0.47',net:2002,adr:[36]} , {type: 8, instance: 48871}, 76, (err, value) => { printResultObject(48871,value); console.log('value: ', value); console.log('err: ', err); });
I attached a json file with the printResultObject value.
resultobject.txt

Below is a screen shot of the json from the attached file visualized. At the top the Type:8 and Instance: 48871 matches the light panel I was trying to read values from. The child objects at the bottom are confusing me because they are Type:12 which I haven't found what object type 12 is. The value is Type: 2 which is analog output and instance: 601 must be the instance of that analog value.

I was able to read the current value of instance 601
bacnetClient.on('listening', () => { bacnetClient.readProperty({address: '10.10.0.47',net:2002,adr:[36]} , {type: 2, instance: 601}, 85, (err, value) => { printResultObject(601,value); console.log('value: ', value); console.log('err: ', err); });
This is a major break through and hopefully this helps anyone else trying to sort out reading properties. Next I will be testing writing to these properties.
image

@Apollon77
Copy link
Collaborator

But you were still not able to get that device by a whoIs call?

@mwitt1337
Copy link
Author

mwitt1337 commented Aug 3, 2020 via email

@mwitt1337
Copy link
Author

mwitt1337 commented Aug 3, 2020 via email

@Apollon77
Copy link
Collaborator

Interesting is - when checking your screenshot above - that the router device returns some more data in the response. maybe we need to look in how/that they are parsed correctly :-(
Maybe @NateZimmer have an idea? The logic should be the same as in the official repo

@NateZimmer
Copy link

To people having the issues:

  • Ensure you run wireshark while performing tests. Wireshark will give you a nice dissection of the who-is response / generic bacnet responses. From there you can tell if the sub devices are actually being reported. Ideally somehow upload the exported pcap filtering on the bacnet port.

@mwitt1337 Regarding this example:
image
Here the network number appears to be 1
Here the network address appears to be a 6 byte MAC address. I take it, this is not a MS/TP device then? MS/TP devices will have a network address of a single byte. TBH I haven't tried/tested on my personal fork of addressing by 6byte MAC address. I wonder if whatever bacnet explorer you are using might be masking the network address though its possible it could be the MAC address. Wireshark will tell you the answer

You should first:

  1. Send a who-is to the bacnet router
  2. Create an iAm event listener and log the iAm responses you get

From there you will know how to address the sub devices

To this repo's maintainers:
What did you do with the iAm event emitter? https://github.com/fh1ch/node-bacstack/blob/master/lib/client.js#L290 .

The iAm event emitter should contain:

  • Address:
    -- Router IP
    -- Network number
    -- Network address
  • Other info (device ID, max apdu, ...etc)

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

No branches or pull requests

5 participants