Implementing Read and Write requests on Outstation

1,660 views
Skip to first unread message

dinakar n

unread,
Aug 12, 2015, 8:51:24 AM8/12/15
to automatak-dnp3

Hi Adam,

I am trying to implement Opendnp3 library for realising outstation functionalities in an existing application, which uses TMW library. This application has its own database implementation and I need to use this db for handling requests. I have gone through Demo application and most of the source files but its still unclear for me to handle Read and Write requests from Master. Can you please provide information about which Interfaces/Classes to be implemented in my application for handling these requests?


Regards,
Dinakar

J Adam Crain

unread,
Aug 12, 2015, 10:46:26 AM8/12/15
to automatak-dnp3
Reads are handled transparently to the user. In other words, opendnp3 does not support external data stores. The application code pushes any changes received, including any initial values into the outstation which has it's own data-structures in memory for the static data and event buffers. Examples of loading this data are found in the samples, e.g.:

https://github.com/automatak/dnp3/blob/2.0.x/cpp/examples/outstation/DemoMain.cpp#L118

You'll have to be more specific about what kind of write you are trying to handle. Opendnp3 doesn't support generic writes for every type imaginable.

-Adam

dinakar n

unread,
Aug 12, 2015, 11:54:28 AM8/12/15
to automatak-dnp3
Hi Adam,

My goal is to verify that Opendnp3 can be used as a substitute for TMW but with a limited scope of functionalities. So for this purpose I was expecting to perform basic operations which includes write operations for atleast one variation for both AnalogOutput and BinaryOutput which is supported, SBO operations and read requests.

To further clarify about our database, we are currently creating an image of all dnp points available on outstation in our application code and these images are used for handling master requests.When Master requests write operation, then respective point values on device are updated. Does this account to external data stores??  If Yes, then per my understanding we can handle only data changes in designed database template, event buffers will be reported to master as shown in demo code.

Regards,
Dinakar

J Adam Crain

unread,
Aug 12, 2015, 1:18:43 PM8/12/15
to automatak-dnp3
Hi Dinakar,

Some comments below.


On Wednesday, August 12, 2015 at 11:54:28 AM UTC-4, dinakar n wrote:
Hi Adam,

My goal is to verify that Opendnp3 can be used as a substitute for TMW but with a limited scope of functionalities. So for this purpose I was expecting to perform basic operations which includes write operations for atleast one variation for both AnalogOutput and BinaryOutput which is supported, SBO operations and read requests.

Analog outputs (group 41) are never "written" in DNP3.  Group 10v1 can be written, but this most certainly deprecated behavior and should be avoided.  If you are referring to handling these objects using the select, operate, or direct operate functions codes, than this is the appropriate callback that you implement and pass into the outstation when you create it:

 

To further clarify about our database, we are currently creating an image of all dnp points available on outstation in our application code and these images are used for handling master requests.When Master requests write operation, then respective point values on device are updated. Does this account to external data stores??  If Yes, then per my understanding we can handle only data changes in designed database template, event buffers will be reported to master as shown in demo code.

That's correct. In opendnp3, you don't have to maintain this collection of points in your application code unless you want to do so. The stack has its own copy and operates off of this copy to automatically handle all types of READ requests. You just push any events/changes into the stack and let it handle processing responses off of its internal state.

With respect to WRITE requests, as I mentioned before, this is not really standards compliant DNP3. There are some objects you can write such as group0 (device attributes), group 34 (analog deadbands), group 50 (time objects), group 70 (file), group 80 (datasets), and group 110-113 octet strings.

Writing other groups is not valid DNP3 and should be avoided.

dinakar n

unread,
Aug 13, 2015, 9:08:36 AM8/13/15
to automatak-dnp3
Adam,

Thanks alot for your reply and providing information in such detail. :)

Regards ,
Dinakar

dinakar n

unread,
Aug 25, 2015, 10:57:18 AM8/25/15
to automatak-dnp3
Hi Adam,

I am trying to pass a command to an outstation for setting a Binaryoutput i.e. Grp12 data point' value. I can see the request entering select/operate block of CROB in SimpleCommandhandler.cpp , here I am missing a link to our database template. Am I missing anything here?. Also, Can you please throw some light on handling Analog Command and CROB commands from this method onwards in a general case.

In adddition, I want the address of point specified by Index in select/operate methods for implementing calls to my existing user code. How can this be achieved? I tried to find methods which can give me point's address for a given index but could not find anything.

One more question, In MeasUpdate.h file I found modify method, can you please tell me its importance and how it is different from Update() in same class.

Regards,
Dinakar

J Adam Crain

unread,
Aug 25, 2015, 11:49:41 AM8/25/15
to automatak-dnp3
Hi Dinakar,

The SimpleCommandHandler is just an example of implemented the underlying interface which is ICommandHandler:


In a real application, you will create your own implementation of this interface to handle incoming control requests. You can create a command handler that does anything you want in response to control messages.

Opendnp3 does not provide a way for you to inspect the current values of measurement data you have loaded into the stack in a general way. If this is required in your application, simply maintain a copy of the data outside of the stack and refer to it whenever a request is received.

The Modify() methods allow you to manipulate the current value in the database using a functor, e.g.:

{
MeasUpdate tx(pOutstation);
auto changeQuality = openpal::Function1<const Binary&, Binary>::Bind([](const Binary& b) { return Binary(b.value, ~0); });
tx.Modify(changeQuality, 1);
}

It is a means to access the value and transform it in some way.

dinakar n

unread,
Aug 26, 2015, 3:19:01 AM8/26/15
to automatak-dnp3
Thanks Adam, It was very helpful. I will work on my implementation of ICommandHandler.h

dinakar n

unread,
Sep 10, 2015, 11:00:14 AM9/10/15
to automatak-dnp3

Hi Adam,

I am trying to set a float value to an analog output status point using command from Master. I am sending a value of '12.5' , but in implementation method of ICommandHandler interface I am receiving a value of '125'. Is it intended to work in this way? Also, How can I recieve an exact float value?

Thanks,
Dinakar

J Adam Crain

unread,
Sep 10, 2015, 5:08:55 PM9/10/15
to automatak-dnp3
Hi,

The stack shouldn't be scaling/truncating anything internally when sending / receiving an analog output.

Which specific type AnalogOutput type are you using on the master? AnalogOutputFloat32 or AnalogOutputDouble64?

-Adam

dinakar n

unread,
Sep 11, 2015, 3:48:32 AM9/11/15
to automatak-dnp3

I used AnalogOutputFloat32 type in above case, but observed similar behavior with AnalogOutputDouble64 type too. I am implementing outstation stack using opendnp3 library and for master using TMW Protocol Test Harness tool.

J Adam Crain

unread,
Sep 11, 2015, 8:46:48 AM9/11/15
to automatak-dnp3
Ok, can you capture a communication log from TMW and opendnp3 and print the value you receive in your ICommandHandler?

My guess is TMW is not sending you what you think they are.

We have pretty good test cases for receiving setpoints so I'd be really surprised if this was a bug on our end:


Best way to resolve it is just to analyze what is being put on the wire.

-Adam

dinakar n

unread,
Sep 15, 2015, 8:06:10 AM9/15/15
to automatak-dnp3
Hi Adam,

I have verified packets using wireshark and could see scaled values being sent from test simulator itself and also it seems to be an old issue with the license version of TMW Test Harness Protocol that we are using.

Regards,
Dinakar

J Adam Crain

unread,
Sep 15, 2015, 8:20:26 AM9/15/15
to automatak-dnp3
Thank you for confirming that this was an issue on the TMW side.

-Adam
Reply all
Reply to author
Forward
0 new messages