Skip to main content

A Python library for connecting to OPC UA servers with OpenSSL support.

Project description

OPC UA Client Library

Overview

This library provides functionality for connecting to OPC UA servers. It requires OpenSSL for cryptographic operations.

Note: This library has been tested only on Windows.

Prerequisites

Before using this library, you need to install OpenSSL and set up your project directory as follows:

root/
├── openssl/
│ └── bin/openssl.exe
└── main.py

Installing OpenSSL on Windows

  1. Download the OpenSSL installer for Windows from the official OpenSSL website.
  2. Install OpenSSL and ensure that openssl.exe is placed in the openssl/bin/ directory of your project.
  3. Ensure that your openssl directory is properly set up according to the structure mentioned above.

Usage

To use this library, you need to set up your main.py file as follows:

import asyncio
from opc_full_connect import create_cert, OPCUAClient

async def main():

    create_cert("certificates", "cert", "pk", "cert")

    opc_url = "your_url"
    opc_username = "username"
    opc_password = "password"
    opc_policy = "policy"
    opc_mode = "mode"
    opc_certificate_path = "cert_path"
    opc_private_key_path = "pk_path"
    opc_application_uri = "urn:freeopcua:client"

    # Create an instance of OPCUAClient
    client_instance = OPCUAClient(opc_url,
                                  opc_policy,
                                  opc_mode,
                                  opc_certificate_path,
                                  opc_private_key_path,
                                  opc_username,
                                  opc_password,
                                  opc_application_uri
                                )

    # Connect to the OPC UA server
    await client_instance.connect_to_opc()

    # ID of the node to retrieve the value from
    node_id = "ns=2;s=2"

    # Retrieve the value of the node
    try:
        node_value = await client_instance.get_node_value(node_id)
        print(f"Value of node {node_id}: {node_value}")
    except Exception as e:
        print(f"Error retrieving node value: {e}")

# Run the main asynchronous function
if __name__ == "__main__":
    asyncio.run(main())

License

This library is licensed under the MIT License. Please refer to the LICENSE file for more details.

Support

For issues or questions, please open an issue on GitHub.

Acknowledgements

This library uses OpenSSL for cryptographic functions. Please refer to the OpenSSL website for more information.

Key Points Covered

  1. Project Structure:

    • Clearly describes the required directory structure and where openssl.exe should be located.
  2. OpenSSL Installation:

    • Provides instructions to install OpenSSL on Windows and place it in the correct directory.
  3. Usage Instructions:

    • Includes a complete example of how to use the library with comments and print statements in English.
  4. License:

    • Specifies the licensing terms under which the library is distributed.
  5. Support:

    • Provides information on how users can get help or report issues.
  6. Acknowledgements:

    • Credits OpenSSL for its role in the library's functionality.

Feel free to adjust the README content based on specific details about your project or any additional information you wish to include.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opc_full_connect-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

opc_full_connect-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file opc_full_connect-0.1.0.tar.gz.

File metadata

  • Download URL: opc_full_connect-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for opc_full_connect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bd085c4e32d7e0229384f00f161343e537e32b01da64f6540c3b89b026de4ac7
MD5 b1e6ad221ef903213833b2e161a57549
BLAKE2b-256 5e0f5cb54a57baa9fc28cdf343dae11394a3022d962eae0db413e048266f64ab

See more details on using hashes here.

File details

Details for the file opc_full_connect-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for opc_full_connect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a7f74f6d7a60926d00b7d00b342176003660186dc99285910a13cff0f440d9c
MD5 72cd539d937f292a1c3763f111e863eb
BLAKE2b-256 038137c3a0198388b882f2745c916f693134e006cef2c831fd7ec7bd47fdf03c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page