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

How to read a specific Object Instance inside a Device Instance #38

Open
1 task
fromnowhereuser opened this issue Jun 25, 2022 · 1 comment
Open
1 task

Comments

@fromnowhereuser
Copy link

fromnowhereuser commented Jun 25, 2022

Node Version: X.Y.Z

Node BACstack Version: X.Y.Z

  • Bug Report
  • [ x ] Feature Request
  • [ x ] Question

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

Feature Request / Question

Hello all, my questio is quite simple, i wanty to read a property (present value for ex) so, the propertyID: 85
To test, i have downloaded this: http://bacnet.sourceforge.net/
and i run this command to query a property:
./bacrp --mac 192.168.1.12 1012 2 13 present-value
or
./bacrp --mac 192.168.1.12 1012 2 13 85

192.168.1.12
is ip of the device i want to query

1012
is the DEVICE instance

2
is the object-type (like analog, etc...)

13
os the OBJECT instance

property
85, for present value according to bacnet protocol.

According to the node-bacstack doc, to read a property, i need to:
const bacnet = require('node-bacnet');
const client = new bacnet();

client.readProperty('192.168.1.43', {type: 8, instance: 44301}, 28, (err, value) => {
console.log('value: ', value);
});

But, i cant put the OBJECT instance somewhere, so... what can i do ? I am quite stuck and i feel i am doing something wrong.. but i can see where

@rristov60
Copy link

Hi, so I assume you want to read a specific object property from a device. In the given example above you are reading the Description of Device object.

Let me elaborate.

The read property function has the following structure:

client.readProperty(deviceIPAddress, { type: objectType, instance: objectInstance }, propertyToRead, (err, value) => {
     console.log('value:', value);
});

The actual device is also considered as an object of type 8 with instance 44301 which is the default instance. This instance essentially is deviceID ( each device has unique ID ), so you can either use the default one or use the actual device ID. Property id: 28 is the description property of the object.

So basically you use the same structure for any object ( as mentioned above the device is an object as well ). The code for the object you gave as an example that you want to read would look like the following:

const bacnet = require('node-bacnet');
const client = new bacnet();

const deviceIp = '192.168.1.12';
const readObject = {
    objectId: {
        type: 2,
        instance: 13
    },
    property: 85
}

client.readProperty(deviceIp, readObject.objectId, readObject.property, (err, value) => {
    console.log('value: ', value);
});

Hope this helps :))

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