re-order how we open the device

David Rebbe 2024-12-03 16:02:28 -05:00
parent fc72d87c76
commit a97f3bf297
1 changed files with 6 additions and 6 deletions

View File

@ -153,20 +153,20 @@ ICSNEO_API icsneo_error_t icsneo_open(icsneo_device_t* device) {
if (!dev->open()) { if (!dev->open()) {
return icsneo_error_open_failed; return icsneo_error_open_failed;
} }
// Go online // Sync RTC
if ((device->options & icsneo_open_options_go_online) == icsneo_open_options_go_online && !dev->goOnline()) { if ((device->options & icsneo_open_options_sync_rtc) == icsneo_open_options_sync_rtc && !dev->setRTC(std::chrono::system_clock::now())) {
dev->close(); dev->close();
return icsneo_error_go_online_failed; return icsneo_error_sync_rtc_failed;
} }
// Enable message polling // Enable message polling
if ((device->options & icsneo_open_options_enable_message_polling) == icsneo_open_options_enable_message_polling && !dev->enableMessagePolling()) { if ((device->options & icsneo_open_options_enable_message_polling) == icsneo_open_options_enable_message_polling && !dev->enableMessagePolling()) {
dev->close(); dev->close();
return icsneo_error_enable_message_polling_failed; return icsneo_error_enable_message_polling_failed;
} }
// Sync RTC // Go online
if ((device->options & icsneo_open_options_sync_rtc) == icsneo_open_options_sync_rtc && !dev->setRTC(std::chrono::system_clock::now())) { if ((device->options & icsneo_open_options_go_online) == icsneo_open_options_go_online && !dev->goOnline()) {
dev->close(); dev->close();
return icsneo_error_sync_rtc_failed; return icsneo_error_go_online_failed;
} }
return icsneo_error_success; return icsneo_error_success;
} }