Skip to content

Commit af66697

Browse files
authored
Merge pull request #29 from arduino-libraries/fix-no-wait-startup
Fix: do no wait for a serial connection on startup.
2 parents 70a243a + 6713ec6 commit af66697

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

examples/opta_opcua_server/opta_opcua_server.ino

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ static PinStatus arduino_opta_digital_read(pin_size_t const pin)
105105
void setup()
106106
{
107107
Serial.begin(115200);
108-
//auto const start = millis();
109-
//for (; !Serial && (millis() - start) < 1000; ) { }
110-
while (!Serial) { }
108+
auto const start = millis();
109+
for (; !Serial && (millis() - start) < 1000; ) { }
111110

112111
#if USE_MODBUS_SENSOR_MD02
113112
RS485.setDelays(MODBUS_PRE_DELAY_BR, MODBUS_POST_DELAY_BR);
@@ -515,6 +514,15 @@ void loop()
515514
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
516515
delay(500);
517516

517+
/* Periodically print OPC UA server IP and port. */
518+
static auto prev_ip_print = millis();
519+
auto const now = millis();
520+
if ((now - prev_ip_print) > 5000)
521+
{
522+
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_SERVER, "Arduino Opta IP: %s", Ethernet.localIP().toString().c_str());
523+
prev_ip_print = now;
524+
}
525+
518526
#if USE_MODBUS_SENSOR_MD02
519527
if (!ModbusRTUClient.requestFrom(MODBUS_DEVICE_ID, INPUT_REGISTERS, MODBUS_DEVICE_TEMPERATURE_REGISTER, 1)) {
520528
Serial.print("failed to read temperature register! ");

0 commit comments

Comments
 (0)