Skip to content

Commit

Permalink
fix std::logic_err when client receive one request two times; add srcipt
Browse files Browse the repository at this point in the history
  • Loading branch information
jason416 committed Aug 23, 2019
1 parent 0dd2885 commit bac2cfe
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
17 changes: 17 additions & 0 deletions my_configure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

export PATH=$PATH:/opt/buildroot-2017.02.5/output/host/usr/bin


./configure CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --host=arm-linux CPPFLAGS="-I/home/jason/lib/arm-python/include -I/home/jason/lib/libxml2/build/include/libxml2 -I/home/jason/lib/libxml2/build/include -I/home/jason/lib/boost" LDFLAGS="-L/home/jason/lib/arm-python/lib -L/home/jason/lib/libxml2/build/lib -L/home/jason/lib/boost/stage/lib" --enable-static=no --prefix=/home/jason/workspace/freeopcua/output

# After configure, DO EDIT Makefile
# 1. change LIBS
# 2. change /usr/include/libxmle to you libxml2 include path, use: %s/\/usr....
# 3. then do make


# Build python ext:
# 1. export CC=arm-linux-gnueabihf-gcc
# 2. export LDSHARED="arm-linux-gnueabihf-gcc -shared"
# 3. python2 setup.py build_ext --include-dirs="/home/jason/lib/boost:/home/jason/lib/arm-python/include/python2.7:/home/jason/lib/libxml2/build/include/libxml2:/home/jason/lib/libxml2/build/include" --library-dirs="/home/jason/lib/arm-python/lib:/home/jason/lib/libxml2/build/lib:/home/jason/lib/boost/stage/lib" --libraries=boost_atomic:boost_python:python2.7
3 changes: 2 additions & 1 deletion python/examples/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
sys.path.append(".")

from IPython import embed
# from IPython import embed
import opcua

class SubHandler(opcua.SubscriptionHandler):
Expand All @@ -19,6 +19,7 @@ def event(self, handle, event):
server = opcua.Server(True)
server.set_endpoint("opc.tcp://localhost:4841/freeopcua/server/")
server.set_server_name("FreeOpcUa Example Server")
server.set_uri("urn://exampleserver.freeopcua.github.io")

# start the server
server.start()
Expand Down
22 changes: 22 additions & 0 deletions python/my_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
python2 setup.py clean
rm -rf build
export PATH=$PATH:/opt/buildroot-2017.02.5/output/host/usr/bin

export CC=arm-linux-gnueabihf-gcc
export LDSHARED="arm-linux-gnueabihf-gcc -shared"

sudo cp /usr/bin/g++ /usr/bin/g++.bak
sudo ln -sf /opt/buildroot-2017.02.5/output/host/usr/bin/arm-linux-gnueabihf-g++ /etc/alternatives/c++
#sudo ln -sf /opt/buildroot-2017.02.5/output/host/usr/bin/arm-linux-gnueabihf-g++ /usr/bin/g++

python2 setup.py build_ext --include-dirs="/home/jason/lib/boost:/home/jason/lib/arm-python/include/python2.7:/home/jason/lib/libxml2/build/include/libxml2:/home/jason/lib/libxml2/build/include" --library-dirs="/home/jason/lib/arm-python/lib:/home/jason/lib/libxml2/build/lib:/home/jason/lib/boost/stage/lib" --libraries="boost_atomic boost_python python2.7"

echo "======================build done==========================="
sudo ln -sf /usr/bin/g++ /etc/alternatives/c++
sudo cp /usr/bin/g++.bak /usr/bin/g++
OBJ=build/lib.linux-x86_64-2.7/opcua.so
arm-linux-gnueabihf-strip $OBJ
echo "======================cp to tftpboot======================="
cp $OBJ /tftpboot

6 changes: 6 additions & 0 deletions src/client/binary_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,12 @@ class BinaryClient
if (callbackIt == Callbacks.end())
{
LOG_WARN(Logger, "binary_client | no callback found for message id: {}, handle: {}", id, header.RequestHandle);
/* 2019-8-22: Changed by jason416, Do clear buffer
* Once we recieve a request alreay handled, buffer must BE CLEANED, otherwise there will be two packet laies in buffer.
* As above, if two buffer are diffrent type request, it will cause logic_error excpetion.
* SO ADD DO CLEAR buffer when wrong packet receive.
*/
messageBuffer.clear();
return;
}

Expand Down

0 comments on commit bac2cfe

Please sign in to comment.