opendnp3 java project

859 views
Skip to first unread message

joe wu

unread,
May 3, 2012, 9:35:20 PM5/3/12
to open-dnp3
Hi,
I am newbie in dnp3 and am going to develop java server on top dnp3,
I am writing my first java server base on dnp3Java. Here is my code
snippet,

VMware with OS: Ubuntu 11.10, 4GB
============== main program =========
stackManager.AddTCPClient("tcpclient", new
PhysLayerSettings(LOG_LEVEL, 3000), "127.0.0.1", 4999);
...
ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);
MyDataObserver myDataObserver = new MyDataObserver();
Runnable masterworker = new MasterRunnable(stackManager,
myDataObserver, LOG_LEVEL);

============= MasterRunnable ==========
MasterStackConfig stackConfig = new MasterStackConfig();
stackConfig.getLink().setLocalAddr(100);
stackConfig.getLink().setRemoteAddr(1);
ICommandAcceptor commandAcceptor =
stackManager.AddMaster("tcpclient", "master", LOG_LEVEL,
myDataObserver , stackConfig);
BinaryOutput bo = new BinaryOutput();
Setpoint sp = new Setpoint();
Binary binary = new Binary();
myDataObserver.swigTakeOwnership();
myDataObserver.Update(binary, 0);
<--------- this line cause SIGSEGV in JNI
============= below is SIGSEGV dump file ======
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fb86357d541, pid=2906,
tid=140429902862080
#
# JRE version: 6.0_23-b23
# Java VM: OpenJDK 64-Bit Server VM (20.0-b11 mixed mode linux-amd64
compressed oops)
# Derivative: IcedTea6 1.11pre
# Distribution: Ubuntu 11.10, package 6b23~pre11-0ubuntu1.11.10.2
# Problematic frame:
# C [libopendnp3.so.0.0.0+0x1c1541]
Java_org_totalgrid_reef_protocol_dnp3_javadnp3JNI_IDataObserver_1Update_1_1SWIG_10+0x11
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

--------------- T H R E A D ---------------

Current thread (0x00000000020f6800): JavaThread "pool-1-
thread-1" [_thread_in_native, id=2932,
stack(0x00007fb86269d000,0x00007fb86279e000)]

siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR),
si_addr=0x0000000000000008

Registers:
RAX=0x0000000000000000, RBX=0x00000000f5d605b8,
RCX=0x00007fb86279c7e8, RDX=0x0000000000000000
RSP=0x00007fb86279c710, RBP=0x00007fb86279c7a0,
RSI=0x00007fb86279c7b0, RDI=0x00000000020f69d0
R8 =0x0000000002100040, R9 =0x00007fb86279c7d0,
R10=0x00007fb8649eab02, R11=0x00007fb86a282360
R12=0x0000000000000000, R13=0x00000000f5d605b8,
R14=0x00007fb86279c7f8, R15=0x00000000020f6800
RIP=0x00007fb86357d541, EFLAGS=0x0000000000010202,
CSGSFS=0x0000000000000033, ERR=0x0000000000000004
TRAPNO=0x000000000000000e

Top of Stack: (sp=0x00007fb86279c710)
0x00007fb86279c710: 00007fb86279c7a0 00007fb8649eab2f
0x00007fb86279c720: 0000000000000000 00000000f5d605b8
0x00007fb86279c730: 0000000000000000 00000000f5d605b8
0x00007fb86279c740: 00007fb86279c7a0 00007fb8649ea733
0x00007fb86279c750: 0000000000000000 00007fb8649ea6ff
0x00007fb86279c760: 00007fb86279c760 00000000f5d605b8
0x00007fb86279c770: 00007fb86279c7f8 00000000f5d75378
0x00007fb86279c780: 0000000000000000 00000000f5d605b8
0x00007fb86279c790: 0000000000000000 00007fb86279c7c0
0x00007fb86279c7a0: 00007fb86279c840 00007fb8649d98da
0x00007fb86279c7b0: 00000000f5d75310 00007fb8649e6278
0x00007fb86279c7c0: 0000000000000000 00007fb86279c7e0
0x00007fb86279c7d0: 00000000cc13a4a8 0000000002100040
0x00007fb86279c7e0: 00000000cc13a4a8 00000000cc0e9210
0x00007fb86279c7f0: 0000000000000000 00000000cc0e9210
0x00007fb86279c800: 00007fb86279c800 00000000f5da880b
0x00007fb86279c810: 00007fb86279c868 00000000f5daab00
0x00007fb86279c820: 0000000000000000 00000000f5da8818
0x00007fb86279c830: 00007fb86279c7c0 00007fb86279c850
0x00007fb86279c840: 00007fb86279c8b0 00007fb8649d98da
0x00007fb86279c850: 0000000000000000 00007fb8649e69ae
0x00007fb86279c860: 00000000cc13a4a8 00000000cc0e9210
0x00007fb86279c870: 00007fb86279c870 00000000f5dab856
0x00007fb86279c880: 00007fb86279c8f8 00000000f5dabc70
0x00007fb86279c890: 0000000000000000 00000000f5dab8f8
0x00007fb86279c8a0: 00007fb86279c850 00007fb86279c8f8
0x00007fb86279c8b0: 00007fb86279c940 00007fb8649d9db4
0x00007fb86279c8c0: 0000000000000000 0000000000000000
0x00007fb86279c8d0: 00000000cc13a4a8 00000000cc12adf8
0x00007fb86279c8e0: 00000000cc126eb8 00000000cc11b740
0x00007fb86279c8f0: 00000000cc117998 00000000cc0ebfb8
0x00007fb86279c900: 00007fb86279c900 00000000f5d85a16

Instructions: (pc=0x00007fb86357d541)
0x00007fb86357d521: 0f 1f 80 00 00 00 00 f3 c3 66 0f 1f 44 00 00 48
0x00007fb86357d531: 83 ec 08 4d 85 c0 48 89 d0 48 8b 54 24 10 74 1f
0x00007fb86357d541: 80 78 08 00 74 2e 48 8b 08 4c 89 c6 48 89 c7 48
0x00007fb86357d551: 8b 49 20 48 83 c4 08 ff e1 66 0f 1f 44 00 00 48

Register to memory mapping:

RAX=0x0000000000000000 is an unknown value
RBX=0x00000000f5d605b8 is an oop
{method}
- klass: {other class}
RCX=0x00007fb86279c7e8 is pointing into the stack for thread:
0x00000000020f6800
RDX=0x0000000000000000 is an unknown value
RSP=0x00007fb86279c710 is pointing into the stack for thread:
0x00000000020f6800
RBP=0x00007fb86279c7a0 is pointing into the stack for thread:
0x00000000020f6800
RSI=0x00007fb86279c7b0 is pointing into the stack for thread:
0x00000000020f6800
RDI=0x00000000020f69d0 is an unknown value
R8 =0x0000000002100040 is an unknown value
R9 =0x00007fb86279c7d0 is pointing into the stack for thread:
0x00000000020f6800
R10=0x00007fb8649eab02 is an Interpreter codelet
method entry point (kind = native) [0x00007fb8649ea660,
0x00007fb8649eb440] 3552 bytes
R11=0x00007fb86a282360: <offset 0x6c0360> in /usr/lib/jvm/java-6-
openjdk/jre/lib/amd64/server/libjvm.so at 0x00007fb869bc2000
R12=0x0000000000000000 is an unknown value
R13=0x00000000f5d605b8 is an oop
{method}
- klass: {other class}
R14=0x00007fb86279c7f8 is pointing into the stack for thread:
0x00000000020f6800
R15=0x00000000020f6800 is a thread


Stack: [0x00007fb86269d000,0x00007fb86279e000],
sp=0x00007fb86279c710, free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code,
C=native code)
C [libopendnp3.so.0.0.0+0x1c1541]
Java_org_totalgrid_reef_protocol_dnp3_javadnp3JNI_IDataObserver_1Update_1_1SWIG_10+0x11
j org.totalgrid.reef.protocol.dnp3.IDataObserver.Update(Lorg/
totalgrid/reef/protocol/dnp3/Binary;J)V+11
j com.sentient_energy.dnp3.server.MasterRunnable.run()V+86
j java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/
concurrent/ThreadPoolExecutor$Worker;)V+46
j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+5
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub
V [libjvm.so+0x4afa5f] JavaCalls::call_helper(JavaValue*,
methodHandle*, JavaCallArguments*, Thread*)+0x29f
V [libjvm.so+0x4aee95] JavaCalls::call(JavaValue*, methodHandle,
JavaCallArguments*, Thread*)+0x25
V [libjvm.so+0x4af393] JavaCalls::call_virtual(JavaValue*,
KlassHandle, symbolHandle, symbolHandle, JavaCallArguments*, Thread*)
+0x1a3
V [libjvm.so+0x4af4bf] JavaCalls::call_virtual(JavaValue*, Handle,
KlassHandle, symbolHandle, symbolHandle, Thread*)+0x4f
V [libjvm.so+0x4e4f76] thread_entry(JavaThread*, Thread*)+0x86
V [libjvm.so+0x74bca8] JavaThread::thread_main_inner()+0x58
V [libjvm.so+0x64bc22] java_start(Thread*)+0x112

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j
org.totalgrid.reef.protocol.dnp3.javadnp3JNI.IDataObserver_Update__SWIG_0(JLorg/
totalgrid/reef/protocol/dnp3/IDataObserver;JLorg/totalgrid/reef/
protocol/dnp3/Binary;J)V+0
j org.totalgrid.reef.protocol.dnp3.IDataObserver.Update(Lorg/
totalgrid/reef/protocol/dnp3/Binary;J)V+11
j com.sentient_energy.dnp3.server.MasterRunnable.run()V+86
j java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/
concurrent/ThreadPoolExecutor$Worker;)V+46
j java.util.concurrent.ThreadPoolExecutor$Worker.run()V+5
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x0000000001f80000 JavaThread "DestroyJavaVM" [_thread_blocked,
id=2909, stack(0x00007fb86b46f000,0x00007fb86b570000)]
=>0x00000000020f6800 JavaThread "pool-1-thread-1" [_thread_in_native,
id=2932, stack(0x00007fb86269d000,0x00007fb86279e000)]
0x0000000002032000 JavaThread "Low Memory Detector" daemon
[_thread_blocked, id=2926,
stack(0x00007fb863906000,0x00007fb863a07000)]
0x000000000202d000 JavaThread "C2 CompilerThread1" daemon
[_thread_blocked, id=2925,
stack(0x00007fb863a07000,0x00007fb863b08000)]
0x000000000202a000 JavaThread "C2 CompilerThread0" daemon
[_thread_blocked, id=2924,
stack(0x00007fb863b08000,0x00007fb863c09000)]
0x000000000201d000 JavaThread "JDWP Command Reader" daemon
[_thread_in_native, id=2922,
stack(0x00007fb863c09000,0x00007fb863d0a000)]
0x000000000201a800 JavaThread "JDWP Event Helper Thread" daemon
[_thread_blocked, id=2921,
stack(0x00007fb863d0a000,0x00007fb863e0b000)]
0x0000000002017000 JavaThread "JDWP Transport Listener: dt_socket"
daemon [_thread_blocked, id=2918,
stack(0x00007fb863e0b000,0x00007fb863f0c000)]
0x000000000200b800 JavaThread "Signal Dispatcher" daemon
[_thread_blocked, id=2916,
stack(0x00007fb864111000,0x00007fb864212000)]
0x0000000001fe8000 JavaThread "Finalizer" daemon [_thread_blocked,
id=2915, stack(0x00007fb864212000,0x00007fb864313000)]
0x0000000001fe6000 JavaThread "Reference Handler" daemon
[_thread_blocked, id=2914,
stack(0x00007fb864313000,0x00007fb864414000)]

Other Threads:
0x0000000001fdf000 VMThread [stack:
0x00007fb864414000,0x00007fb864515000] [id=2913]
0x0000000002035000 WatcherThread [stack:
0x00007fb863805000,0x00007fb863906000] [id=2927]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 9664K, used 1291K [0x00000000cc000000,
0x00000000cca70000, 0x00000000d9e00000)
eden space 8640K, 14% used [0x00000000cc000000, 0x00000000cc142ce0,
0x00000000cc870000)
from space 1024K, 0% used [0x00000000cc870000, 0x00000000cc870000,
0x00000000cc970000)
to space 1024K, 0% used [0x00000000cc970000, 0x00000000cc970000,
0x00000000cca70000)
tenured generation total 21504K, used 0K [0x00000000d9e00000,
0x00000000db300000, 0x00000000f5a00000)
the space 21504K, 0% used [0x00000000d9e00000,
0x00000000d9e00000, 0x00000000d9e00200, 0x00000000db300000)
compacting perm gen total 21248K, used 3818K [0x00000000f5a00000,
0x00000000f6ec0000, 0x0000000100000000)
the space 21248K, 17% used [0x00000000f5a00000,
0x00000000f5dbab60, 0x00000000f5dbac00, 0x00000000f6ec0000)
No shared spaces configured.

Code Cache [0x00007fb8649d4000, 0x00007fb864c44000,
0x00007fb8679d4000)
total_blobs=201 nmethods=2 adapters=162 free_code_cache=49928000
largest_free_block=7360

Dynamic libraries:
00400000-00409000 r-xp 00000000 08:01
925294 /usr/lib/jvm/java-6-openjdk/jre/bin/
java
00608000-00609000 r--p 00008000 08:01
925294 /usr/lib/jvm/java-6-openjdk/jre/bin/
java
00609000-0060a000 rw-p 00009000 08:01
925294 /usr/lib/jvm/java-6-openjdk/jre/bin/
java
01f73000-021b0000 rw-p 00000000 00:00
0 [heap]
cc000000-cca70000 rw-p 00000000 00:00 0
cca70000-d9e00000 rw-p 00000000 00:00 0
d9e00000-db300000 rw-p 00000000 00:00 0
db300000-f5a00000 rw-p 00000000 00:00 0
f5a00000-f6ec0000 rw-p 00000000 00:00 0
f6ec0000-100000000 rw-p 00000000 00:00 0
7fb86269d000-7fb8626a0000 ---p 00000000 00:00 0
7fb8626a0000-7fb86279e000 rw-p 00000000 00:00 0
7fb86279e000-7fb86279f000 ---p 00000000 00:00 0
7fb86279f000-7fb862f9f000 rw-p 00000000 00:00 0
7fb862f9f000-7fb862fa2000 r-xp 00000000 08:01
807151 /usr/lib/libboost_system.so.1.46.1
7fb862fa2000-7fb8631a1000 ---p 00003000 08:01
807151 /usr/lib/libboost_system.so.1.46.1
7fb8631a1000-7fb8631a2000 r--p 00002000 08:01
807151 /usr/lib/libboost_system.so.1.46.1
7fb8631a2000-7fb8631a3000 rw-p 00003000 08:01
807151 /usr/lib/libboost_system.so.1.46.1
7fb8631a3000-7fb8631ba000 r-xp 00000000 08:01
808008 /usr/lib/libboost_thread.so.1.46.1
7fb8631ba000-7fb8633b9000 ---p 00017000 08:01
808008 /usr/lib/libboost_thread.so.1.46.1
7fb8633b9000-7fb8633bb000 r--p 00016000 08:01
808008 /usr/lib/libboost_thread.so.1.46.1
7fb8633bb000-7fb8633bc000 rw-p 00018000 08:01
808008 /usr/lib/libboost_thread.so.1.46.1
7fb8633bc000-7fb8635df000 r-xp 00000000 08:01
812373 /usr/lib/libopendnp3.so.0.0.0
7fb8635df000-7fb8637de000 ---p 00223000 08:01
812373 /usr/lib/libopendnp3.so.0.0.0
7fb8637de000-7fb863802000 r--p 00222000 08:01
812373 /usr/lib/libopendnp3.so.0.0.0
7fb863802000-7fb863803000 rw-p 00246000 08:01
812373 /usr/lib/libopendnp3.so.0.0.0
7fb863803000-7fb863805000 rw-p 00000000 00:00 0
7fb863805000-7fb863806000 ---p 00000000 00:00 0
7fb863806000-7fb863906000 rw-p 00000000 00:00 0
7fb863906000-7fb863909000 ---p 00000000 00:00 0
7fb863909000-7fb863a07000 rw-p 00000000 00:00 0
7fb863a07000-7fb863a0a000 ---p 00000000 00:00 0
7fb863a0a000-7fb863b08000 rw-p 00000000 00:00 0
7fb863b08000-7fb863b0b000 ---p 00000000 00:00 0
7fb863b0b000-7fb863c09000 rw-p 00000000 00:00 0
7fb863c09000-7fb863c0c000 ---p 00000000 00:00 0
7fb863c0c000-7fb863d0a000 rw-p 00000000 00:00 0
7fb863d0a000-7fb863d0d000 ---p 00000000 00:00 0
7fb863d0d000-7fb863e0b000 rw-p 00000000 00:00 0
7fb863e0b000-7fb863e0e000 ---p 00000000 00:00 0
7fb863e0e000-7fb863f0c000 rw-p 00000000 00:00 0
7fb863f0c000-7fb863f10000 r-xp 00000000 08:01
925334 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libdt_socket.so
7fb863f10000-7fb86410f000 ---p 00004000 08:01
925334 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libdt_socket.so
7fb86410f000-7fb864110000 r--p 00003000 08:01
925334 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libdt_socket.so
7fb864110000-7fb864111000 rw-p 00004000 08:01
925334 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libdt_socket.so
7fb864111000-7fb864114000 ---p 00000000 00:00 0
7fb864114000-7fb864212000 rw-p 00000000 00:00 0
7fb864212000-7fb864215000 ---p 00000000 00:00 0
7fb864215000-7fb864313000 rw-p 00000000 00:00 0
7fb864313000-7fb864316000 ---p 00000000 00:00 0
7fb864316000-7fb864414000 rw-p 00000000 00:00 0
7fb864414000-7fb864415000 ---p 00000000 00:00 0
7fb864415000-7fb864548000 rw-p 00000000 00:00 0
7fb864548000-7fb8646d8000 r--s 037ba000 08:01
925984 /usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar
7fb8646d8000-7fb86470b000 rw-p 00000000 00:00 0
7fb86470b000-7fb864754000 rw-p 00000000 00:00 0
7fb864754000-7fb86475f000 rw-p 00000000 00:00 0
7fb86475f000-7fb864833000 rw-p 00000000 00:00 0
7fb864833000-7fb864839000 rw-p 00000000 00:00 0
7fb864839000-7fb8648a2000 rw-p 00000000 00:00 0
7fb8648a2000-7fb8648ad000 rw-p 00000000 00:00 0
7fb8648ad000-7fb864980000 rw-p 00000000 00:00 0
7fb864980000-7fb86498b000 rw-p 00000000 00:00 0
7fb86498b000-7fb8649d3000 rw-p 00000000 00:00 0
7fb8649d3000-7fb8649d4000 rw-p 00000000 00:00 0
7fb8649d4000-7fb864c44000 rwxp 00000000 00:00 0
7fb864c44000-7fb8679d4000 rw-p 00000000 00:00 0
7fb8679d4000-7fb8679db000 r-xp 00000000 08:01
925968 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libzip.so
7fb8679db000-7fb867bda000 ---p 00007000 08:01
925968 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libzip.so
7fb867bda000-7fb867bdb000 r--p 00006000 08:01
925968 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libzip.so
7fb867bdb000-7fb867bdc000 rw-p 00007000 08:01
925968 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libzip.so
7fb867bdc000-7fb867be8000 r-xp 00000000 08:01
406374 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fb867be8000-7fb867de7000 ---p 0000c000 08:01
406374 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fb867de7000-7fb867de8000 r--p 0000b000 08:01
406374 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fb867de8000-7fb867de9000 rw-p 0000c000 08:01
406374 /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fb867de9000-7fb867df3000 r-xp 00000000 08:01
406376 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fb867df3000-7fb867ff3000 ---p 0000a000 08:01
406376 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fb867ff3000-7fb867ff4000 r--p 0000a000 08:01
406376 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fb867ff4000-7fb867ff5000 rw-p 0000b000 08:01
406376 /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fb867ff5000-7fb86800c000 r-xp 00000000 08:01
406371 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fb86800c000-7fb86820b000 ---p 00017000 08:01
406371 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fb86820b000-7fb86820c000 r--p 00016000 08:01
406371 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fb86820c000-7fb86820d000 rw-p 00017000 08:01
406371 /lib/x86_64-linux-gnu/libnsl-2.13.so
7fb86820d000-7fb86820f000 rw-p 00000000 00:00 0
7fb86820f000-7fb868217000 r-xp 00000000 08:01
406372 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fb868217000-7fb868416000 ---p 00008000 08:01
406372 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fb868416000-7fb868417000 r--p 00007000 08:01
406372 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fb868417000-7fb868418000 rw-p 00008000 08:01
406372 /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fb868418000-7fb86899b000 r--p 00000000 08:01
793820 /usr/lib/locale/locale-archive
7fb86899b000-7fb86899e000 r-xp 00000000 08:01
925960 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libnpt.so
7fb86899e000-7fb868b9d000 ---p 00003000 08:01
925960 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libnpt.so
7fb868b9d000-7fb868b9e000 r--p 00002000 08:01
925960 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libnpt.so
7fb868b9e000-7fb868b9f000 rw-p 00003000 08:01
925960 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libnpt.so
7fb868b9f000-7fb868bd9000 r-xp 00000000 08:01
925959 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjdwp.so
7fb868bd9000-7fb868dd8000 ---p 0003a000 08:01
925959 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjdwp.so
7fb868dd8000-7fb868dd9000 r--p 00039000 08:01
925959 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjdwp.so
7fb868dd9000-7fb868dda000 rw-p 0003a000 08:01
925959 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjdwp.so
7fb868dda000-7fb868e06000 r-xp 00000000 08:01
925967 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjava.so
7fb868e06000-7fb869005000 ---p 0002c000 08:01
925967 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjava.so
7fb869005000-7fb869006000 r--p 0002b000 08:01
925967 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjava.so
7fb869006000-7fb869009000 rw-p 0002c000 08:01
925967 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libjava.so
7fb869009000-7fb869017000 r-xp 00000000 08:01
925523 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libverify.so
7fb869017000-7fb869216000 ---p 0000e000 08:01
925523 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libverify.so
7fb869216000-7fb869218000 r--p 0000d000 08:01
925523 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libverify.so
7fb869218000-7fb869219000 rw-p 0000f000 08:01
925523 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
libverify.so
7fb869219000-7fb869220000 r-xp 00000000 08:01
406381 /lib/x86_64-linux-gnu/librt-2.13.so
7fb869220000-7fb86941f000 ---p 00007000 08:01
406381 /lib/x86_64-linux-gnu/librt-2.13.so
7fb86941f000-7fb869420000 r--p 00006000 08:01
406381 /lib/x86_64-linux-gnu/librt-2.13.so
7fb869420000-7fb869421000 rw-p 00007000 08:01
406381 /lib/x86_64-linux-gnu/librt-2.13.so
7fb869421000-7fb869436000 r-xp 00000000 08:01
405033 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb869436000-7fb869635000 ---p 00015000 08:01
405033 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb869635000-7fb869636000 r--p 00014000 08:01
405033 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb869636000-7fb869637000 rw-p 00015000 08:01
405033 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fb869637000-7fb8696ba000 r-xp 00000000 08:01
406369 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8696ba000-7fb8698b9000 ---p 00083000 08:01
406369 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8698b9000-7fb8698ba000 r--p 00082000 08:01
406369 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8698ba000-7fb8698bb000 rw-p 00083000 08:01
406369 /lib/x86_64-linux-gnu/libm-2.13.so
7fb8698bb000-7fb8699a3000 r-xp 00000000 08:01
789059 /usr/lib/x86_64-linux-gnu/libstdc++.so.
6.0.16
7fb8699a3000-7fb869ba3000 ---p 000e8000 08:01
789059 /usr/lib/x86_64-linux-gnu/libstdc++.so.
6.0.16
7fb869ba3000-7fb869bab000 r--p 000e8000 08:01
789059 /usr/lib/x86_64-linux-gnu/libstdc++.so.
6.0.16
7fb869bab000-7fb869bad000 rw-p 000f0000 08:01
789059 /usr/lib/x86_64-linux-gnu/libstdc++.so.
6.0.16
7fb869bad000-7fb869bc2000 rw-p 00000000 00:00 0
7fb869bc2000-7fb86a4c5000 r-xp 00000000 08:01
925971 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
server/libjvm.so
7fb86a4c5000-7fb86a6c4000 ---p 00903000 08:01
925971 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
server/libjvm.so
7fb86a6c4000-7fb86a745000 r--p 00902000 08:01
925971 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
server/libjvm.so
7fb86a745000-7fb86a760000 rw-p 00983000 08:01
925971 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
server/libjvm.so
7fb86a760000-7fb86a789000 rw-p 00000000 00:00 0
7fb86a789000-7fb86a7a0000 r-xp 00000000 08:01
393547 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7fb86a7a0000-7fb86a99f000 ---p 00017000 08:01
393547 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7fb86a99f000-7fb86a9a0000 r--p 00016000 08:01
393547 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7fb86a9a0000-7fb86a9a1000 rw-p 00017000 08:01
393547 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7fb86a9a1000-7fb86ab38000 r-xp 00000000 08:01
406365 /lib/x86_64-linux-gnu/libc-2.13.so
7fb86ab38000-7fb86ad37000 ---p 00197000 08:01
406365 /lib/x86_64-linux-gnu/libc-2.13.so
7fb86ad37000-7fb86ad3b000 r--p 00196000 08:01
406365 /lib/x86_64-linux-gnu/libc-2.13.so
7fb86ad3b000-7fb86ad3c000 rw-p 0019a000 08:01
406365 /lib/x86_64-linux-gnu/libc-2.13.so
7fb86ad3c000-7fb86ad42000 rw-p 00000000 00:00 0
7fb86ad42000-7fb86ad44000 r-xp 00000000 08:01
406368 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb86ad44000-7fb86af44000 ---p 00002000 08:01
406368 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb86af44000-7fb86af45000 r--p 00002000 08:01
406368 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb86af45000-7fb86af46000 rw-p 00003000 08:01
406368 /lib/x86_64-linux-gnu/libdl-2.13.so
7fb86af46000-7fb86af4a000 r-xp 00000000 08:01
925382 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
jli/libjli.so
7fb86af4a000-7fb86b149000 ---p 00004000 08:01
925382 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
jli/libjli.so
7fb86b149000-7fb86b14a000 r--p 00003000 08:01
925382 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
jli/libjli.so
7fb86b14a000-7fb86b14b000 rw-p 00004000 08:01
925382 /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/
jli/libjli.so
7fb86b14b000-7fb86b163000 r-xp 00000000 08:01
406379 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb86b163000-7fb86b362000 ---p 00018000 08:01
406379 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb86b362000-7fb86b363000 r--p 00017000 08:01
406379 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb86b363000-7fb86b364000 rw-p 00018000 08:01
406379 /lib/x86_64-linux-gnu/libpthread-2.13.so
7fb86b364000-7fb86b368000 rw-p 00000000 00:00 0
7fb86b368000-7fb86b389000 r-xp 00000000 08:01
406362 /lib/x86_64-linux-gnu/ld-2.13.so
7fb86b38b000-7fb86b38e000 r--s 0007d000 08:01
923301 /usr/lib/jvm/java-6-openjdk/jre/lib/
jsse.jar
7fb86b38e000-7fb86b391000 r--s 00016000 08:01
931609 /usr/share/java/opendnp3.jar
7fb86b391000-7fb86b392000 r--s 00002000 08:01
418552 /home/wchung/workspace/test/lib/slf4j-
log4j12-1.6.4.jar
7fb86b392000-7fb86b393000 r--s 00005000 08:01
418081 /home/wchung/workspace/test/lib/slf4j-
api.jar
7fb86b393000-7fb86b39c000 r--s 0006d000 08:01
418635 /home/wchung/workspace/test/lib/
log4j-1.2.16.jar
7fb86b39c000-7fb86b39e000 r--s 00007000 08:01
927772 /usr/share/java/hamcrest-core-1.1.jar
7fb86b39e000-7fb86b3a0000 r--s 00007000 08:01
927772 /usr/share/java/hamcrest-core-1.1.jar
7fb86b3a0000-7fb86b3a7000 r--s 00030000 08:01
927841 /usr/share/java/junit4-4.8.2.jar
7fb86b3a7000-7fb86b3af000 r--s 00066000 08:01
927905 /usr/share/java/gnome-java-bridge.jar
7fb86b3af000-7fb86b3b9000 rw-p 00000000 00:00 0
7fb86b3b9000-7fb86b46f000 rw-p 00000000 00:00 0
7fb86b46f000-7fb86b472000 ---p 00000000 00:00 0
7fb86b472000-7fb86b575000 rw-p 00000000 00:00 0
7fb86b57a000-7fb86b57c000 r--s 0000f000 08:01
923287 /usr/lib/jvm/java-6-openjdk/jre/lib/ext/
pulse-java.jar
7fb86b57c000-7fb86b584000 rw-s 00000000 08:01
393978 /tmp/hsperfdata_wchung/2906
7fb86b584000-7fb86b585000 rw-p 00000000 00:00 0
7fb86b585000-7fb86b586000 r--p 00000000 00:00 0
7fb86b586000-7fb86b588000 rw-p 00000000 00:00 0
7fb86b588000-7fb86b589000 r--p 00020000 08:01
406362 /lib/x86_64-linux-gnu/ld-2.13.so
7fb86b589000-7fb86b58b000 rw-p 00021000 08:01
406362 /lib/x86_64-linux-gnu/ld-2.13.so
7fffdf122000-7fffdf143000 rw-p 00000000 00:00
0 [stack]
7fffdf1cb000-7fffdf1cc000 r-xp 00000000 00:00
0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00
0 [vsyscall]

VM Arguments:
jvm_args: -
agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:51071 -
Dfile.encoding=UTF-8
java_command: com.sentient_energy.dnp3.server.DnpServer
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/
sbin:/usr/bin:/sbin:/bin:/usr/games
USERNAME=wchung
LD_LIBRARY_PATH=/usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/
lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/
jre/../lib/amd64
SHELL=/bin/bash
DISPLAY=:0

Signal Handlers:
SIGSEGV: [libjvm.so+0x783e60], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGBUS: [libjvm.so+0x783e60], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGFPE: [libjvm.so+0x6485c0], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGPIPE: [libjvm.so+0x6485c0], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGXFSZ: [libjvm.so+0x6485c0], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGILL: [libjvm.so+0x6485c0], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000000
SIGUSR2: [libjvm.so+0x648770], sa_mask[0]=0x00000004,
sa_flags=0x10000004
SIGHUP: [libjvm.so+0x64b280], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGINT: [libjvm.so+0x64b280], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGTERM: [libjvm.so+0x64b280], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004
SIGQUIT: [libjvm.so+0x64b280], sa_mask[0]=0x7ffbfeff,
sa_flags=0x10000004


--------------- S Y S T E M ---------------

OS:Ubuntu 11.10 (oneiric)
uname:Linux 3.0.0-17-generic #30-Ubuntu SMP Thu Mar 8 20:45:39 UTC
2012 x86_64
libc:glibc 2.13 NPTL 2.13
rlimit: STACK 8192k, CORE 0k, NPROC 15928, NOFILE 4096, AS infinity
load average:0.33 0.54 0.41

/proc/meminfo:
MemTotal: 2056724 kB
MemFree: 206704 kB
Buffers: 152296 kB
Cached: 667760 kB
SwapCached: 0 kB
Active: 1232892 kB
Inactive: 460964 kB
Active(anon): 874456 kB
Inactive(anon): 1556 kB
Active(file): 358436 kB
Inactive(file): 459408 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 522236 kB
SwapFree: 522236 kB
Dirty: 84 kB
Writeback: 0 kB
AnonPages: 873796 kB
Mapped: 146956 kB
Shmem: 2216 kB
Slab: 98032 kB
SReclaimable: 81956 kB
SUnreclaim: 16076 kB
KernelStack: 2696 kB
PageTables: 21380 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 1550596 kB
Committed_AS: 2131192 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 274084 kB
VmallocChunk: 34359461312 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 36864 kB
DirectMap2M: 2060288 kB


CPU:total 1 (1 cores per cpu, 1 threads per core) family 6 model 42
stepping 7, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1,
sse4.2, popcnt

Memory: 4k page, physical 2056724k(206704k free), swap 522236k(522236k
free)

vm_info: OpenJDK 64-Bit Server VM (20.0-b11) for linux-amd64 JRE
(1.6.0_23-b23), built on Feb 23 2012 05:39:46 by "buildd" with gcc
4.6.1

time: Thu May 3 18:18:04 2012
elapsed time: 7 seconds

=======================================

Question 1. Is any Java example?
QUestion 2. based on my code snippet, what did I do wrong?

Christopher Verges

unread,
May 4, 2012, 2:13:21 AM5/4/12
to open...@googlegroups.com
Hi Joe,

It looks like this is due to the SwigDirector_DataPoint::ToString() method:

cverges@cverges-dev-lnx:~/opendnp3/.libs$ gdb libopendnp3.so.0.0.0
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /home/cverges/opendnp3/.libs/libopendnp3.so.0.0.0...done.
(gdb) info symbol 0x1c1541
SwigDirector_DataPoint::ToString() const + 417 in section .text
(gdb) 

It looks like this is defined in the javadnp3JNI.java file.  The function itself has the following code:

685   public static String SwigDirector_DataPoint_ToString(DataPoint self) {
686     return self.ToString();
687   }

So I took a look at the Binary class itself.  It's generated by Swig.  When I traced into the constructor that you're using -- Binary() -- it calls the javadnp3JNI.new_Binary__SWIG_2() function.  The function appears to be defined, but I can't find it implemented.

cverges@cverges-dev-lnx:~/opendnp3$ grep -r new_Binary__SWIG_2 .
./java/src/org/totalgrid/reef/protocol/dnp3/Binary.java:    this(javadnp3JNI.new_Binary__SWIG_2(), true);
./java/src/org/totalgrid/reef/protocol/dnp3/javadnp3JNI.java:  public final static native long new_Binary__SWIG_2();

Unfortunately, I'm already out of my element as soon as Swig is mentioned.  (Long live C/C++!)  Sam or Adam, you guys deal with Java a lot ... any ideas?

Chris

Sam Hendley

unread,
May 4, 2012, 9:58:51 AM5/4/12
to open...@googlegroups.com
Hi Joe, there are a few issues with the snippet you sent, I'll try to address all of them but first I'll answer your direct questions.

Question 1. Is any Java example?
There is no separate example for the java code, but since the objects are identical to their c++ counter parts the c++ demos will show how to use the objects (there are a few caveats ill address in a moment.)

We have demos of both slave side and master side communication:

There is also an example of using the wrapped java dnp3 library in the reef project. It is however "production code" and written in scala so don't expect a step-by-step tutorial of usage, it may take a bit of digging.

QUestion 2. based on my code snippet, what did I do wrong? 

From the example you provided the main issue is that you are not doing a "Transaction" on the datasource. You would need to write:

Binary binary = new Binary();
myDataObserver.Start();
myDataObserver.Update(binary, 0); 
myDataObserver.End();

If you study the c++ examples it should become more clear how to use the dnp3 objects correctly. 
            
There are a few caveats to using the stack from java that should help you and others trying to use it from java.
  • Never call any of the "swig generated" functions like swigTakeOwnership or delete
  • Keep explicit references to all objects you pass into the c++ stack. The SWIG director system is supposed to keep track of objects and stop them being garbage collected but we haven't had success getting that to work. This is true of both "live" objects like listeners and callbacks and configuration objects (which may be accessed by the stack at any time). If you are getting unexpected segfaults it is almost always related to the garbage collector cleaning up java objects that are being referenced by the c++ stack. This can be tricky to see because it will generally appear to work for a while until a GC occurs.
  • If you are getting errors during initialization of the stack and object it is possible that there is an inconsistency between the compiled library version and the java bindings. Building libjavadnp3.so on your machine from source fixes a large number of issues.

Please take a look at the c++ examples and let us know where you get.

Sam

joe wu

unread,
May 4, 2012, 7:32:33 PM5/4/12
to open-dnp3
Thanks Sam and Chris, also bear with a newbie

Some background for this thread, I am trying to write my first Java
server and client side is SlaveDemo.cpp
This will be our model eventually, my Java server with thrid party CPP
client.
All code from DNP3 seems compiled/built fine,

I've read C++ code -- MasterDemo.cpp, there is QueueingFDO where there
is NO corresponding Java class!

Now back to my Java code

I have an empty wrapper
public class MyDataObserver extends IDataObserver {
public MyDataObserver() {
// To be implements
}
// To be implements
}

MyDataObserver myDataObserver = new MyDataObserver();
ICommandAcceptor commandAcceptor = stackManager.AddMaster("tcpclient",
"master", LOG_LEVEL, myDataObserver , stackConfig);

Q1. How do I use myDataObserver, Since there is no QueueingFDO, how
do I simulate cpp server getting the update?

Q2. I also try as you suggested

ICommandAcceptor commandAcceptor = stackManager.AddMaster("tcpclient",
"master", LOG_LEVEL, myDataObserver , stackConfig);
BinaryOutput bo = new BinaryOutput();
Setpoint sp = new Setpoint();
Binary binary = new Binary();
myDataObserver.Start(); // <------------------ core dump right away
in JNI code, core dump can provide if help

Q3. There is several Update methods for different prupose , Binary,
Analog ...etc
Is any way Server know incoming message is Binary, Analog ..
etc.

Much appreciate
Joe




On May 4, 6:58 am, Sam Hendley <sam.hend...@gmail.com> wrote:
> Hi Joe, there are a few issues with the snippet you sent, I'll try to
> address all of them but first I'll answer your direct questions.
>
> Question 1. Is any Java example?
> There is no separate example for the java code, but since the objects are
> identical to their c++ counter parts the c++ demos will show how to use the
> objects (there are a few caveats ill address in a moment.)
>
> We have demos of both slave side and master side communication:https://github.com/gec/dnp3/blob/master/demos/master-cpp/MasterDemo.cpphttps://github.com/gec/dnp3/blob/master/demos/slave-cpp/SlaveDemo.cpp
>
> There is also an example of using the wrapped java dnp3 library in the reef
> project. It is however "production code" and written in scala so don't
> expect a step-by-step tutorial of usage, it may take a bit of digging.https://github.com/gec/reef/tree/master/protocol-dnp3
>
> QUestion 2. based on my code snippet, what did I do wrong?
>
> From the example you provided the main issue is that you are not doing a
> "Transaction" on the datasource. You would need to write:
>
> Binary binary = new Binary();
> myDataObserver.Start();
> myDataObserver.Update(binary, 0);
> myDataObserver.End();
>
> If you study the c++ examples it should become more clear how to use the
> dnp3 objects correctly.
>
> There are a few caveats to using the stack from java that should help you
> and others trying to use it from java.
>
>    - Never call any of the "swig generated" functions like
>    swigTakeOwnership or delete
>    - Keep explicit references to all objects you pass into the c++ stack.
>    The SWIG director system is supposed to keep track of objects and stop them
>    being garbage collected but we haven't had success getting that to work.
>    This is true of both "live" objects like listeners and callbacks and
>    configuration objects (which may be accessed by the stack at any time). If
>    you are getting unexpected segfaults it is almost always related to the
>    garbage collector cleaning up java objects that are being referenced by the
>    c++ stack. This can be tricky to see because it will generally appear to
>    work for a while until a GC occurs.
>    - If you are getting errors during initialization of the stack and
>    object it is possible that there is an inconsistency between the compiled
>    library version and the java bindings. Building libjavadnp3.so on your
>    machine from source fixes a large number of issues.
>
> Please take a look at the c++ examples and let us know where you get.
>
> Sam
>
> On Fri, May 4, 2012 at 2:13 AM, Christopher Verges
> <chris.ver...@gmail.com>wrote:
>
>
>
> > Hi Joe,
>
> > It looks like this is due to the SwigDirector_DataPoint::ToString() method:
>
> > cverges@cverges-dev-lnx:~/opendnp3/.libs$ *gdb libopendnp3.so.0.0.0*
> > GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
> > Copyright (C) 2011 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later <
> >http://gnu.org/licenses/gpl.html>
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> > and "show warranty" for details.
> > This GDB was configured as "x86_64-linux-gnu".
> > For bug reporting instructions, please see:
> > <http://bugs.launchpad.net/gdb-linaro/>...
> > Reading symbols from
> > /home/cverges/opendnp3/.libs/libopendnp3.so.0.0.0...done.
> > (gdb) *info symbol 0x1c1541*
> > SwigDirector_DataPoint::ToString() const + 417 in section .text
> > (gdb)
>
> > It looks like this is defined in the javadnp3JNI.java file.  The function
> > itself has the following code:
>
> >  685   public static String SwigDirector_DataPoint_ToString(DataPoint
> > self) {
> > 686     return self.ToString();
> > 687   }
>
> > So I took a look at the Binary class itself.  It's generated by Swig.
> >  When I traced into the constructor that you're using -- Binary() -- it
> > calls the javadnp3JNI.new_Binary__SWIG_2() function.  The function appears
> > to be defined, but I can't find it implemented.
>
> > cverges@cverges-dev-lnx:~/opendnp3$ grep -r new_Binary__SWIG_2 .
> > ./java/src/org/totalgrid/reef/protocol/dnp3/Binary.java:
> >  this(javadnp3JNI.new_Binary__SWIG_2(), true);
> > ./java/src/org/totalgrid/reef/protocol/dnp3/javadnp3JNI.java:  public
> > final static native long new_Binary__SWIG_2();
>
> > Unfortunately, I'm already out of my element as soon as Swig is mentioned.
> >  (Long live C/C++!)  Sam or Adam, you guys deal with Java a lot ... any
> > ideas?
>
> > Chris
>
> >> Java_org_totalgrid_reef_protocol_dnp3_javadnp3JNI_IDataObserver_1Update_1_1­SWIG_10+0x11
> ...
>
> read more »

Sam Hendley

unread,
May 7, 2012, 6:06:35 PM5/7/12
to open...@googlegroups.com
This test case has the best example of how to use the dnp3 bindings from java and shows the flow needed to use the library.
https://github.com/gec/reef/blob/master/protocol-dnp3/src/test/scala/org/totalgrid/reef/protocol/dnp3/DNP3BindingTest.scala 

In a nutshell that process is:

  • Create dnp3 stack manager (new StackManager)
  • Create listener callbacks for the channel status, stack status (IStackObserver) and incoming measurements (IDataObserver)
  • Add the channel you are using (for a master this will generally be the slaves IP address)
  • Add the master and pass in our data observer, the return value is a commandAcceptor for issuing commands to the slave device.
  • Measurements will start flowing as soon as the master connects to the slave. Measurements come in groups and the updates to the dataobserver are passed in using a transaction. The stack will call Start(), call Update() once for each object passed in, and finally End().
  • When the application is done with the stack, they should remove the master with RemoveStack() and also call Shutdown() on the manager when shutting down the whole application.

In regards to the current issue you are having with a core dump I found the cause. To implement IDataObserver you need to implement _Start, _End and _Update for all of the message types. The c++ definition is here:

https://github.com/gec/dnp3/blob/master/APL/DataInterfaces.h#L44 

It appears that the SWIG generated wrappers include a partial definition of the _Start, _End, _Update functions so java doesn't warn us that we need to implement those methods, just lets us segfault. I'm not sure if this was always the case with SWIG bindings or if something changed in a later version of swig once our java classes were all implemented. This is a serious pitfall and limitation to the SWIG tool, we'll have to address this the dnp3java readme.

Our IDataObserver implementation in greenbus implements all of those functions and works well:
One other thing to note is that is very problematic if exceptions "bubble up" out of java back into c++. Therefore you should make sure every callback from c++ to java (_Start, _Update, _End) is surrounded with a try/catch block if it might possibly cause an exception. The other thing to note is that the dnp3 stack is effectively single threaded so it is important to not block the stack for very long, so if handling the incoming data is a slow process its important to push that work into another thread.

Stuart Statman

unread,
May 7, 2012, 6:23:59 PM5/7/12
to open...@googlegroups.com
This is a great piece of documentation.
--
Stu Statman
VP of Engineering
Sunverge, Inc
http://www.sunverge.com

Christopher Verges

unread,
May 7, 2012, 7:26:37 PM5/7/12
to open...@googlegroups.com
I agree with Stuart's assessment.  These kinds of helpful tidbits would be fantastic to add to the docbook documentation started in the project folder.

Chris
Reply all
Reply to author
Forward
0 new messages