Skip to content

Commit 0f8ef0f

Browse files
committed
Fix: we need to supply the direct channel number as a parameter (1, 2, 3, 4, ...) not OA_PWM_CH_FIRST ... (8, 9, 10, 11, ...) because that's what getPwmPeriod expects.
1 parent d54d655 commit 0f8ef0f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

examples/opcua_server/opcua_server.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void setup()
360360
},
361361
[i, p](void) -> uint32_t
362362
{
363-
return reinterpret_cast<AnalogExpansion *>(OptaController.getExpansionPtr(i))->getPwmPeriod(p);
363+
return reinterpret_cast<AnalogExpansion *>(OptaController.getExpansionPtr(i))->getPwmPeriod(p - OA_PWM_CH_FIRST);
364364
});
365365
pwm_output_num++;
366366
}

src/io/pwm/PwmOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ PwmOutput::onReadRequestPwmPeriod(
186186
UA_Variant_setScalar(&in_x_val_opcua_variant, &in_x_val_opcua_value, &UA_TYPES[UA_TYPES_UINT32]);
187187
UA_Server_writeValue(server, *node_id, in_x_val_opcua_variant);
188188
/* Some debug output. */
189-
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "%s: value = %d", __PRETTY_FUNCTION__, in_x_val);
189+
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "%s: pwm period = %d ms", __PRETTY_FUNCTION__, in_x_val);
190190
}
191191

192192
void

0 commit comments

Comments
 (0)