File syn_opcua.c¶
FileList > proto > syn_opcua.c
Go to the source code of this file
Micro OPC UA (IEC 62541) Binary Protocol Engine & Embedded Server Implementation.
#include "../port/syn_port_system.h"#include "syn_opcua.h"#include <string.h>
Classes¶
| Type | Name |
|---|---|
| struct | OPCUA_Reader Binary deserializer context for OPC UA messages. |
| struct | OPCUA_Writer Binary serializer context for OPC UA messages. |
Public Functions¶
| Type | Name |
|---|---|
| SYN_OPCUA_Node * | syn_opcua_server_find_node_num (SYN_OPCUA_Server * srv, uint16_t ns, uint32_t num_id) Find a node in the address space by numeric NodeId. |
| SYN_Status | syn_opcua_server_init (SYN_OPCUA_Server * srv, const SYN_OPCUA_Config * cfg) Initialize Micro OPC UA Server. |
| SYN_Status | syn_opcua_server_process_message (SYN_OPCUA_Server * srv, const uint8_t * rx, size_t rx_len, uint8_t * tx, size_t max_tx, size_t * out_len) Process an incoming raw OPC UA frame and generate a response frame. |
| SYN_PT_Status | syn_opcua_server_pt (SYN_PT * pt, SYN_Task * task) Protothread continuation function for syn_sched . |
| SYN_Status | syn_opcua_server_read_variable (const SYN_OPCUA_Server * srv, uint16_t ns, uint32_t num_id, SYN_OPCUA_Variant * out_val) Read a variable node's value from the address space. |
| SYN_Status | syn_opcua_server_register_node (SYN_OPCUA_Server * srv, const SYN_OPCUA_Node * node) Register a Node in the server address space. |
| SYN_Status | syn_opcua_server_step (SYN_OPCUA_Server * srv, uint32_t now_ms) Advance OPC UA server state machine by one step / tick. |
| SYN_Status | syn_opcua_server_write_variable (SYN_OPCUA_Server * srv, uint16_t ns, uint32_t num_id, const SYN_OPCUA_Variant * val) Update a variable node's value in the address space. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | opcua_populate_standard_nodes (SYN_OPCUA_Server * srv) Populate default standard OPC UA address space folders and server status node. |
| bool | opcua_read_nodeid_num (OPCUA_Reader * r, uint16_t * out_ns, uint32_t * out_num) Read numeric OPC UA NodeId. |
| bool | opcua_read_u16 (OPCUA_Reader * r, uint16_t * out) Read 16-bit little-endian unsigned integer. |
| bool | opcua_read_u32 (OPCUA_Reader * r, uint32_t * out) Read 32-bit little-endian unsigned integer. |
| bool | opcua_read_u8 (OPCUA_Reader * r, uint8_t * out) Read 8-bit unsigned integer. |
| void | opcua_reader_init (OPCUA_Reader * r, const uint8_t * buf, size_t size) Initialize OPC UA binary reader. |
| bool | opcua_write_bytes (OPCUA_Writer * w, const uint8_t * buf, size_t len) Write raw byte buffer. |
| bool | opcua_write_datavalue (OPCUA_Writer * w, const SYN_OPCUA_DataValue * dv) Write OPC UA DataValue structure. |
| bool | opcua_write_nodeid_num (OPCUA_Writer * w, uint16_t ns, uint32_t num) Write numeric OPC UA NodeId. |
| bool | opcua_write_string (OPCUA_Writer * w, const char * str) Write length-prefixed OPC UA string. |
| bool | opcua_write_u16 (OPCUA_Writer * w, uint16_t v) Write 16-bit little-endian unsigned integer. |
| bool | opcua_write_u32 (OPCUA_Writer * w, uint32_t v) Write 32-bit little-endian unsigned integer. |
| bool | opcua_write_u64 (OPCUA_Writer * w, uint64_t v) Write 64-bit little-endian unsigned integer. |
| bool | opcua_write_u8 (OPCUA_Writer * w, uint8_t v) Write 8-bit unsigned integer. |
| bool | opcua_write_variant (OPCUA_Writer * w, const SYN_OPCUA_Variant * var) Write OPC UA variant value. |
| void | opcua_writer_init (OPCUA_Writer * w, uint8_t * buf, size_t size) Initialize OPC UA binary writer. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_OPCUA_REQ_ACTIVATE_SESSION 467UOPC UA ActivateSessionRequest NodeId. |
| define | SYN_OPCUA_REQ_BROWSE 527UOPC UA BrowseRequest NodeId. |
| define | SYN_OPCUA_REQ_CLOSE_SESSION 473UOPC UA CloseSessionRequest NodeId. |
| define | SYN_OPCUA_REQ_CREATE_SESSION 461UOPC UA CreateSessionRequest NodeId. |
| define | SYN_OPCUA_REQ_READ 631UOPC UA ReadRequest NodeId. |
| define | SYN_OPCUA_REQ_WRITE 673UOPC UA WriteRequest NodeId. |
| define | SYN_OPCUA_RESP_ACTIVATE_SESSION 470UOPC UA ActivateSessionResponse NodeId. |
| define | SYN_OPCUA_RESP_BROWSE 530UOPC UA BrowseResponse NodeId. |
| define | SYN_OPCUA_RESP_CLOSE_SESSION 476UOPC UA CloseSessionResponse NodeId. |
| define | SYN_OPCUA_RESP_CREATE_SESSION 464UOPC UA CreateSessionResponse NodeId. |
| define | SYN_OPCUA_RESP_READ 634UOPC UA ReadResponse NodeId. |
| define | SYN_OPCUA_RESP_WRITE 676UOPC UA WriteResponse NodeId. |
Public Functions Documentation¶
function syn_opcua_server_find_node_num¶
Find a node in the address space by numeric NodeId.
SYN_OPCUA_Node * syn_opcua_server_find_node_num (
SYN_OPCUA_Server * srv,
uint16_t ns,
uint32_t num_id
)
Parameters:
srvServer instance.nsNamespace index.num_idNumeric identifier.
Returns:
Pointer to node in address space or NULL if not found.
function syn_opcua_server_init¶
Initialize Micro OPC UA Server.
Parameters:
srvServer instance to initialize.cfgServer configuration.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on invalid argument.
function syn_opcua_server_process_message¶
Process an incoming raw OPC UA frame and generate a response frame.
SYN_Status syn_opcua_server_process_message (
SYN_OPCUA_Server * srv,
const uint8_t * rx,
size_t rx_len,
uint8_t * tx,
size_t max_tx,
size_t * out_len
)
Parameters:
srvServer instance.rxInbound raw message frame.rx_lenInbound length in bytes.txOutbound response frame buffer.max_txOutbound buffer capacity.out_lenPointer receiving generated response length.
Returns:
SYN_OK on success.
function syn_opcua_server_pt¶
Protothread continuation function for syn_sched .
Parameters:
ptProtothread continuation structure.taskTask handle containing SYN_OPCUA_Server in user_data.
Returns:
SYN_PT_Status continuation status.
function syn_opcua_server_read_variable¶
Read a variable node's value from the address space.
SYN_Status syn_opcua_server_read_variable (
const SYN_OPCUA_Server * srv,
uint16_t ns,
uint32_t num_id,
SYN_OPCUA_Variant * out_val
)
Parameters:
srvServer instance.nsNamespace index.num_idNumeric identifier.out_valOutput variant value pointer.
Returns:
SYN_OK on success, SYN_ERROR if not found.
function syn_opcua_server_register_node¶
Register a Node in the server address space.
Parameters:
srvServer instance.nodeNode descriptor to copy into address space.
Returns:
SYN_OK on success, SYN_ERROR if address space is full.
function syn_opcua_server_step¶
Advance OPC UA server state machine by one step / tick.
Parameters:
srvServer instance.now_msCurrent system timestamp in milliseconds.
Returns:
SYN_OK on success.
function syn_opcua_server_write_variable¶
Update a variable node's value in the address space.
SYN_Status syn_opcua_server_write_variable (
SYN_OPCUA_Server * srv,
uint16_t ns,
uint32_t num_id,
const SYN_OPCUA_Variant * val
)
Parameters:
srvServer instance.nsNamespace index.num_idNumeric identifier.valNew variant value.
Returns:
SYN_OK on success, SYN_ERROR if not found.
Public Static Functions Documentation¶
function opcua_populate_standard_nodes¶
Populate default standard OPC UA address space folders and server status node.
Parameters:
srvServer instance pointer.
function opcua_read_nodeid_num¶
Read numeric OPC UA NodeId.
Parameters:
rReader context.out_nsPointer to receive namespace index.out_numPointer to receive numeric identifier.
Returns:
True on success, false on invalid format or underflow.
function opcua_read_u16¶
Read 16-bit little-endian unsigned integer.
Parameters:
rReader context.outPointer to receive value.
Returns:
True on success, false on underflow.
function opcua_read_u32¶
Read 32-bit little-endian unsigned integer.
Parameters:
rReader context.outPointer to receive value.
Returns:
True on success, false on underflow.
function opcua_read_u8¶
Read 8-bit unsigned integer.
Parameters:
rReader context.outPointer to receive value.
Returns:
True on success, false on underflow.
function opcua_reader_init¶
Initialize OPC UA binary reader.
Parameters:
rReader context.bufInput buffer.sizeInput buffer size.
function opcua_write_bytes¶
Write raw byte buffer.
Parameters:
wWriter context.bufSource bytes.lenNumber of bytes.
Returns:
True on success, false on overflow.
function opcua_write_datavalue¶
Write OPC UA DataValue structure.
Parameters:
wWriter context.dvDataValue structure pointer.
Returns:
True on success, false on error.
function opcua_write_nodeid_num¶
Write numeric OPC UA NodeId.
Parameters:
wWriter context.nsNamespace index.numNumeric identifier.
Returns:
True on success, false on overflow.
function opcua_write_string¶
Write length-prefixed OPC UA string.
Parameters:
wWriter context.strNull-terminated string or NULL for null string.
Returns:
True on success, false on overflow.
function opcua_write_u16¶
Write 16-bit little-endian unsigned integer.
Parameters:
wWriter context.vValue to write.
Returns:
True on success, false on overflow.
function opcua_write_u32¶
Write 32-bit little-endian unsigned integer.
Parameters:
wWriter context.vValue to write.
Returns:
True on success, false on overflow.
function opcua_write_u64¶
Write 64-bit little-endian unsigned integer.
Parameters:
wWriter context.vValue to write.
Returns:
True on success, false on overflow.
function opcua_write_u8¶
Write 8-bit unsigned integer.
Parameters:
wWriter context.vValue to write.
Returns:
True on success, false on overflow.
function opcua_write_variant¶
Write OPC UA variant value.
Parameters:
wWriter context.varVariant structure pointer.
Returns:
True on success, false on serialization error.
function opcua_writer_init¶
Initialize OPC UA binary writer.
Parameters:
wWriter context.bufOutput buffer.sizeOutput buffer size.
Macro Definition Documentation¶
define SYN_OPCUA_REQ_ACTIVATE_SESSION¶
OPC UA ActivateSessionRequest NodeId.
define SYN_OPCUA_REQ_BROWSE¶
OPC UA BrowseRequest NodeId.
define SYN_OPCUA_REQ_CLOSE_SESSION¶
OPC UA CloseSessionRequest NodeId.
define SYN_OPCUA_REQ_CREATE_SESSION¶
OPC UA CreateSessionRequest NodeId.
define SYN_OPCUA_REQ_READ¶
OPC UA ReadRequest NodeId.
define SYN_OPCUA_REQ_WRITE¶
OPC UA WriteRequest NodeId.
define SYN_OPCUA_RESP_ACTIVATE_SESSION¶
OPC UA ActivateSessionResponse NodeId.
define SYN_OPCUA_RESP_BROWSE¶
OPC UA BrowseResponse NodeId.
define SYN_OPCUA_RESP_CLOSE_SESSION¶
OPC UA CloseSessionResponse NodeId.
define SYN_OPCUA_RESP_CREATE_SESSION¶
OPC UA CreateSessionResponse NodeId.
define SYN_OPCUA_RESP_READ¶
OPC UA ReadResponse NodeId.
define SYN_OPCUA_RESP_WRITE¶
OPC UA WriteResponse NodeId.
The documentation for this class was generated from the following file src/syntropic/proto/syn_opcua.c