open-dnp3 C# - Serial test question

697 views
Skip to first unread message

fookj...@live.com.au

unread,
Nov 24, 2013, 8:35:32 PM11/24/13
to automat...@googlegroups.com

Hi Adam and fellow group members,
                                                    I am new to open-dnp3 library and also DNP3 protocol. I have used the open-DNP3 library to simulate some traffic on a 4-port serial board. Would like to ask if anyone knows how I can catch the raw serial stream data? I have been able to use an external application for serial monitoring to acquire the raw serial data, but I would like to capture it in a C# thread to manipulate the DNP3 protocol to other protocol. I understand that MS windows only permits single serial port access to one application, please do let me know if you lot have some idea to help me out on this project. Thank you all very much for your input.

Cheers,
Bryant

J Adam Crain

unread,
Nov 24, 2013, 9:36:12 PM11/24/13
to automat...@googlegroups.com
Hi Bryant,

There are various serial port monitors for Windows that will allow you to monitor traffic passively:


Opendnp3 does not have an option for logging raw bytes (although it probably should).  If you want to log/print incoming packets, do it here:


You can convert the function paramters  (uint8_t* apBuff, size_t aSize) to a hex string using ToHex.h:



-Adam

fookj...@live.com.au

unread,
Nov 24, 2013, 10:06:33 PM11/24/13
to automat...@googlegroups.com
Hi Adam,
             Awesome suggestions, I will get right into it. Thank you for the reply.

Cheers,
Bryant

fookj...@live.com.au

unread,
Nov 25, 2013, 7:09:32 PM11/25/13
to automat...@googlegroups.com

Hi Adam and fellow group members,
                                                    After the suggestion posted by Adam yesterday, I manage to dump a log of the serial data into a .txt document. I am thinking if there is a way to real-time print on the console. If that is possible how can I do it. Thank you for your suggestions :D
 
Cheers,
Bryant

J Adam Crain

unread,
Nov 26, 2013, 8:29:53 AM11/26/13
to automat...@googlegroups.com
Bryant,

Did you insert file output code in the physical layer where I provided the link?

If you want to add this to the logging system, just make a log call here:


If you make a call to the logger with the Hex traffic, that can be directed to the console or file via a log backend.

For instance, this logging backend prints all messages to the console:


-Adam

fookj...@live.com.au

unread,
Nov 26, 2013, 7:13:13 PM11/26/13
to automat...@googlegroups.com
Good day Adam,
                        Thank you for the more detailed pointers. I have learnt how to print on the console via LOG_DEBUG. :D Which I think is not the proper way, so I will implement your suggestions. Appreciating the opendnp3 group Support.

From,
Bryant
Reply all
Reply to author
Forward
0 new messages