Skip to content

Commit 993d200

Browse files
committed
Correct Interval/Delay value
The Interval/Delay value has been incorrectly set in older versions to 0, which causes an ArgumentOutOfRange exception upon connecting the UPS. Make sure this value is corrected when Prefs are updated, and make sure the Prefs form validates the field.
1 parent 314e651 commit 993d200

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

WinNUT_V2/WinNUT-Client/Pref_Gui.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Public Class Pref_Gui
246246
LogFile.LogTracing(String.Format("Check that the value of {0} for {1} is correct.", sender.Text, sender.Name), LogLvl.LOG_DEBUG, Me)
247247
Select Case sender.Name
248248
Case "Tb_Delay_Com"
249-
MinValue = 0
249+
MinValue = 1
250250
MaxValue = 60
251251
Case "Tb_Port"
252252
MinValue = 1

WinNUT_V2/WinNUT-Client/WinNUT.vb

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -846,25 +846,11 @@ Public Class WinNUT
846846
LogFile.DeleteLogFile()
847847
End If
848848

849-
'Dim NeedReconnect As Boolean = False
850-
851-
'With UPS_Device.Nut_Config
852-
' If .AutoReconnect <> Arr_Reg_Key.Item("autoreconnect") Or
853-
' .Host <> Arr_Reg_Key.Item("ServerAddress") Or
854-
' .Port <> Arr_Reg_Key.Item("Port") Or
855-
' .UPSName <> Arr_Reg_Key.Item("UPSName") Or
856-
' UPS_Device.PollingInterval <> Arr_Reg_Key.Item("Delay") Or
857-
' .Login <> Arr_Reg_Key.Item("NutLogin") Or
858-
' UPS_Device.NutPassword <> Arr_Reg_Key.Item("NutPassword") Then
859-
' NeedReconnect = True
860-
' UPS_Device.NutPassword = Arr_Reg_Key.Item("NutPassword")
861-
' End If
862-
' If UPS_Device.UPS_Follow_FSD <> Arr_Reg_Key.Item("Follow_FSD") Then
863-
' UPS_Device.UPS_Follow_FSD = Arr_Reg_Key.Item("Follow_FSD")
864-
' End If
865-
' UPS_Device.Battery_Limit = Arr_Reg_Key.Item("ShutdownLimitBatteryCharge")
866-
' UPS_Device.Backup_Limit = Arr_Reg_Key.Item("ShutdownLimitUPSRemainTime")
867-
'End With
849+
' Validate interval value because it's been incorrectly stored in older versions.
850+
If Arr_Reg_Key.Item("Delay") <= 0 Then
851+
LogFile.LogTracing("Incorrect value of " & Arr_Reg_Key.Item("Delay") & " for Delay/Interval, resetting to default.", LogLvl.LOG_ERROR, Me)
852+
Arr_Reg_Key.Item("Delay") = 1000
853+
End If
868854

869855
' Automatically reconnect if already connected and prefs are changed.
870856
If (UPS_Device IsNot Nothing) AndAlso UPS_Device.IsConnected And isChanged Then

0 commit comments

Comments
 (0)