Skip to content

Commit

Permalink
de1: Handle heater voltage being an empty string
Browse files Browse the repository at this point in the history
A newly connected DE1 may not yet have been queried for its line
voltage when frequency estimation begins. Although
::settings(heater_voltage) exists, it may be an empty string.

Resolve by returning False as is already the case when undefined.

Note the Tcl inconsistency behing the logic:

    % set n ""
    % string is double $n
    1
    % expr { double($n) }
    expected floating-point number but got ""

Signed-Off-By: Jeff Kletsky <[email protected]>
  • Loading branch information
jeffsf authored and Mimoja committed Apr 15, 2021
1 parent c12baf4 commit dac1635
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion de1plus/de1_de1.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ namespace eval ::de1 {

proc line_voltage_nom {} {

if {[info exists ::settings(heater_voltage)]} {
# string is double "" returns 1, expr {double("")} is an error

if {[info exists ::settings(heater_voltage)] \
&& [string is double $::settings(heater_voltage)] \
&& $::settings(heater_voltage) != "" } {
return [expr { double($::settings(heater_voltage)) }]
} else {
return False
Expand Down

0 comments on commit dac1635

Please sign in to comment.