charlie007
Programmer
I can not figure out how to define a hex number 80
I'm using this:
set hexb [binary format H* 80]
I am sending $hexb as part of a string to serial port (see program below). I put on serial port monitor and see 3F as the data. Don't know why 80 is not being sent, yet [format %2X [scan $hexb %c]] displays 80.
If I use
set hexb [binary format H* 81]
hex 81 is sent OK.
Also tried:
set hexb [binary format B* 10000000]
with same results (0x3F)
Please help.
if { [catch {set comport5 [open "com5" "r+"]} fid] } {
set ans [tk_messageBox -message "com5-$fid" -title "OPEN ERROR" -type ok -icon question]
exit
}
fconfigure $comport5 -mode "14400,n,8,1"
set hexa [binary format H* 63]
set hexb [binary format H* 80]
set hexc [binary format H* 63]
set hexd [binary format H* 81]
while {0==0} {
set ans [tk_messageBox -message "yes=0x[format %2X [scan $hexa %c]] 0x[format %2X [scan $hexb %c]] no=0x[format %2X [scan $hexc %c]] 0x[format %2X [scan $hexd %c]] cancel=exit" -type yesnocancel -default yes -icon question -title "USB relay 1"]
switch -exact -- $ans {
yes {set c "x$hexa$hexb//"}
no {set c "x$hexc$hexd//"}
cancel {break}
}
puts -nonewline $comport5 $c
flush $comport5
}
close $comport5
exit
I'm using this:
set hexb [binary format H* 80]
I am sending $hexb as part of a string to serial port (see program below). I put on serial port monitor and see 3F as the data. Don't know why 80 is not being sent, yet [format %2X [scan $hexb %c]] displays 80.
If I use
set hexb [binary format H* 81]
hex 81 is sent OK.
Also tried:
set hexb [binary format B* 10000000]
with same results (0x3F)
Please help.
if { [catch {set comport5 [open "com5" "r+"]} fid] } {
set ans [tk_messageBox -message "com5-$fid" -title "OPEN ERROR" -type ok -icon question]
exit
}
fconfigure $comport5 -mode "14400,n,8,1"
set hexa [binary format H* 63]
set hexb [binary format H* 80]
set hexc [binary format H* 63]
set hexd [binary format H* 81]
while {0==0} {
set ans [tk_messageBox -message "yes=0x[format %2X [scan $hexa %c]] 0x[format %2X [scan $hexb %c]] no=0x[format %2X [scan $hexc %c]] 0x[format %2X [scan $hexd %c]] cancel=exit" -type yesnocancel -default yes -icon question -title "USB relay 1"]
switch -exact -- $ans {
yes {set c "x$hexa$hexb//"}
no {set c "x$hexc$hexd//"}
cancel {break}
}
puts -nonewline $comport5 $c
flush $comport5
}
close $comport5
exit