Code Monkey home page Code Monkey logo

Comments (10)

oroulet avatar oroulet commented on July 19, 2024

first attempt with ctypes lead to a coredump. Any suggestions?

 from ctypes import cdll

  if __name__ == "__main__":
       libua = cdll.LoadLibrary("./libopen62541.so")
      config = libua.UA_ServerConfig_standard
       nl = libua.UA_ServerNetworkLayerTCP(libua.UA_ConnectionConfig_standard, 16664)

coredump here

from opcua-modeler.

Pro avatar Pro commented on July 19, 2024

open62541 only uses python for code generation from XML, there is no python wrapper as far as I know.
Starting the server externally shouldn't be a problem because you can use custom signals (e.g. SIGUSR1) and catch that in the open62541 implementation to shut it down properly.
I think that's the easiest solution.

I never worked with ctypes.
Also note that the current release RC1 has some problems with undefined stuff if you use the example code. I suggesst using the 0.2 branch.

And: your mention of jprf is wrong, the correct one would be jpfr ;)

from opcua-modeler.

oroulet avatar oroulet commented on July 19, 2024

I think that's the easiest solution

Sounds boring ;-) we'll make styles worth

On Sun, Nov 13, 2016, 12:51 Stefan Profanter [email protected]
wrote:

open62541 only uses python for code generation from XML, there is no
python wrapper as far as I know.
Starting the server externally shouldn't be a problem because you can use
custom signals (e.g. SIGUSR1) and catch that in the open62541
implementation to shut it down properly.
I think that's the easiest solution.

I never worked with ctypes.
Also note that the current release RC1 has some problems with undefined
stuff if you use the example code. I suggesst using the 0.2 branch.

And: your mention of jprf is wrong, the correct one would be jpfr ;)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#24 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACcfzljfI3hJMLuplA_Jpx5m09DF6Y3uks5q9vncgaJpZM4KwoVP
.

from opcua-modeler.

oroulet avatar oroulet commented on July 19, 2024

Styles -> ctypes . stupid auto correction..

On Sun, Nov 13, 2016, 17:57 Olivier Roulet-Dubonnet <
[email protected]> wrote:

I think that's the easiest solution

Sounds boring ;-) we'll make styles worth

On Sun, Nov 13, 2016, 12:51 Stefan Profanter [email protected]
wrote:

open62541 only uses python for code generation from XML, there is no
python wrapper as far as I know.
Starting the server externally shouldn't be a problem because you can use
custom signals (e.g. SIGUSR1) and catch that in the open62541
implementation to shut it down properly.
I think that's the easiest solution.

I never worked with ctypes.
Also note that the current release RC1 has some problems with undefined
stuff if you use the example code. I suggesst using the 0.2 branch.

And: your mention of jprf is wrong, the correct one would be jpfr ;)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#24 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACcfzljfI3hJMLuplA_Jpx5m09DF6Y3uks5q9vncgaJpZM4KwoVP
.

from opcua-modeler.

oroulet avatar oroulet commented on July 19, 2024

@Pro looks like I get a crash when calling things which are plugins... Are the plugins automatically loaded? Can i force loading?

from opcua-modeler.

Pro avatar Pro commented on July 19, 2024

It depends how you build the library... There are various compile switches in CMake. I think you need to analyze the core dumps further to see where exactly it fails.

from opcua-modeler.

oroulet avatar oroulet commented on July 19, 2024

OK. ctypes works fine. It was a stupid typo on my side. but there are a lot of boring structs to expose, and possible fragility since structs are mined with so #ifdef that change structs at compile time. I am considering looking at cython

from opcua-modeler.

jpfr avatar jpfr commented on July 19, 2024

I wrote a wrapper for open62541 and lua(jit).
That what quite a nice experience. It's like 2k lines of C-code to expose the OPC UA type system to native lua. However, that code will stay internal.

ua = require("libua")

-- define a callback method
function hello_world(object_id, arg1)
    return "Hello " .. arg1.value
end

-- initialize the server with a port number
server = ua.Server(4842)

-- add a method node
string_arg = ua.types.Argument()
string_arg.dataType = ua.types.String.typeId
string_arg.valueRank = -1 -- argument is scalar
input_args = { string_arg } -- list of arguments
output_args = { string_arg }
attr = ua.types.MethodAttributes()
attr.displayName = ua.types.LocalizedText("", "Hello World")
attr.executable = true
browsename = ua.types.QualifiedName(1, "hello_world")
nodeid = ua.types.NodeId(1, "helloworld")
parent = ua.nodeIds.Objects
parent_reference = ua.nodeIds.HasComponent
server:addMethodNode(nodeid, parent, parent_reference,
    browsename, attr, hello_world,
    input_args, output_args)

server:run()

open62541 uses the generated data types quite a lot in the public API.
From my experience with the lua wrapper, it is better to write generic type handling functions that take the datatype description (the UA_DataType) as an additional input. For example by having python "objects" that contain a pointer to the C-data as well as the datatype struct.
Otherwise, there will be many thousands of lines of code just to get from Python to C-representations.

from opcua-modeler.

jpfr avatar jpfr commented on July 19, 2024

Overall, it might even be easier to write a smallish C-extension for Python.
https://docs.python.org/3/extending/building.html

from opcua-modeler.

oroulet avatar oroulet commented on July 19, 2024

Done using cython

from opcua-modeler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.