rendered paste bodyproc sendCommand {rig command} {
puts -nonewline $rig "$command\r"
flush $rig
}
proc readResult {rig} {
set result ""
while {1} {
set ch [read $rig 1]
if {$ch == "\n"} {
break
}
set result "$result$ch"
}
return $result
}
proc getFrequency {rig vfo} {
global VFO_B
set vfo "A"
if {$vfo == $VFO_B} {
set vfo "B"
}
sendCommand $rig "?$vfo"
set hexFreq [readResult $rig]
puts [string length $hexFreq]
#binary scan $hexFreq @1I freq
#return $freq
# Debugging
binary scan $hexFreq c* data
foreach byte $data {
puts [expr {$byte & 0xff}]
}
return "0"
}
set rig [open "/dev/tty.KeySerial1" r+]
fconfigure $rig -mode "57600,n,8,1" -buffering none
set freq [getFrequency $rig $VFO_A]
puts $freq
close $rig