Skip to content

Commit 0194701

Browse files
don't read ptp if not initialized
1 parent 34a8cba commit 0194701

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

NetX/src/u_nx_ethernet.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,15 @@ UINT ethernet_mqtt_reconnect(void) {
525525
#endif
526526

527527
NX_PTP_DATE_TIME ethernet_get_time(void) {
528-
NX_PTP_TIME tm;
529-
NX_PTP_DATE_TIME date;
528+
NX_PTP_TIME tm = { 0 };
529+
NX_PTP_DATE_TIME date = { 0 };
530+
531+
/* If not initialized, don't try to read PTP yet. */
532+
if(!device.is_initialized) {
533+
PRINTLN_ERROR("Tried getting PTP time before device has been initialized.");
534+
return date;
535+
}
536+
530537
/* read the PTP clock */
531538
nx_ptp_client_time_get(&device.ptp_client, &tm);
532539

0 commit comments

Comments
 (0)