Skip to content

Commit ff9e303

Browse files
committed
Fix: also update state of internal member variables when reading back.
1 parent 3ee5179 commit ff9e303

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/io/pwm/PwmOutput.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,15 @@ PwmOutput::onReadRequestPwmPeriod(
244244
UA_NodeId const * node_id)
245245
{
246246
/* Obtain the value of the analog input pin. */
247-
uint32_t const in_x_val = _get_pwm_period_func();
247+
_pwm_period_us = _get_pwm_period_func();
248248
/* Update the variable node. */
249-
UA_UInt32 in_x_val_opcua_value = in_x_val;
249+
UA_UInt32 in_x_val_opcua_value = _pwm_period_us;
250250
UA_Variant in_x_val_opcua_variant;
251251
UA_Variant_init(&in_x_val_opcua_variant);
252252
UA_Variant_setScalar(&in_x_val_opcua_variant, &in_x_val_opcua_value, &UA_TYPES[UA_TYPES_UINT32]);
253253
UA_Server_writeValue(server, *node_id, in_x_val_opcua_variant);
254254
/* Some debug output. */
255-
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "%s: pwm period = %d us", __PRETTY_FUNCTION__, in_x_val);
255+
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "%s: pwm period = %d us", __PRETTY_FUNCTION__, _pwm_period_us);
256256
}
257257

258258
void
@@ -272,15 +272,15 @@ PwmOutput::onReadRequestPwmPulseWidth(
272272
UA_NodeId const * node_id)
273273
{
274274
/* Obtain the value of the analog input pin. */
275-
uint32_t const in_x_val = _get_pwm_pulse_width_func();
275+
_pwm_pulse_width_us = _get_pwm_pulse_width_func();
276276
/* Update the variable node. */
277-
UA_UInt32 in_x_val_opcua_value = in_x_val;
277+
UA_UInt32 in_x_val_opcua_value = _pwm_pulse_width_us;
278278
UA_Variant in_x_val_opcua_variant;
279279
UA_Variant_init(&in_x_val_opcua_variant);
280280
UA_Variant_setScalar(&in_x_val_opcua_variant, &in_x_val_opcua_value, &UA_TYPES[UA_TYPES_UINT32]);
281281
UA_Server_writeValue(server, *node_id, in_x_val_opcua_variant);
282282
/* Some debug output. */
283-
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "%s: pwm pulse width = %d us", __PRETTY_FUNCTION__, in_x_val);
283+
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "%s: pwm pulse width = %d us", __PRETTY_FUNCTION__, _pwm_pulse_width_us);
284284
}
285285

286286
void

0 commit comments

Comments
 (0)