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
- Download the OpenSSL installer for Windows from the official OpenSSL website.
- Install OpenSSL and ensure that
openssl.exe
is placed in theopenssl/bin/
directory of your project. - 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
-
Project Structure:
- Clearly describes the required directory structure and where
openssl.exe
should be located.
- Clearly describes the required directory structure and where
-
OpenSSL Installation:
- Provides instructions to install OpenSSL on Windows and place it in the correct directory.
-
Usage Instructions:
- Includes a complete example of how to use the library with comments and print statements in English.
-
License:
- Specifies the licensing terms under which the library is distributed.
-
Support:
- Provides information on how users can get help or report issues.
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd085c4e32d7e0229384f00f161343e537e32b01da64f6540c3b89b026de4ac7 |
|
MD5 | b1e6ad221ef903213833b2e161a57549 |
|
BLAKE2b-256 | 5e0f5cb54a57baa9fc28cdf343dae11394a3022d962eae0db413e048266f64ab |
File details
Details for the file opc_full_connect-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: opc_full_connect-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a7f74f6d7a60926d00b7d00b342176003660186dc99285910a13cff0f440d9c |
|
MD5 | 72cd539d937f292a1c3763f111e863eb |
|
BLAKE2b-256 | 038137c3a0198388b882f2745c916f693134e006cef2c831fd7ec7bd47fdf03c |