archie/tcl-dp/tests/ser_xmit.test
2024-05-27 16:13:40 +02:00

50 lines
1.1 KiB
Plaintext

# We can't test the serial port send/recv since
# there is no way to do it locally.
#
# You must define a variable "hookedup" that is
# set when there is a NULL modem setup on the first
# serial port of each machine or change the dp_connect
# line below to the correct port.
#
# You must also define a variable "send" or
# "recv" in the two interpreters.
#
# Test send/receive
#
if {[info exists hookedup] == 1} {
if {[string compare test [info procs test]] == 1} then {source ../tests/defs}
set sock1 [dp_connect serial -device serial1]
if {[info exists send] == 1} {
puts stdout "We're sending ..."
test serialxmit-1.0.0 {send serial} {
list [catch {
puts $sock1 "Test 1"
} msg] $msg
} {0 {}}
}
if {[info exists recv] == 1} {
puts stdout "We're receiving ..."
test serialxmit-1.0.0 {read serial} {
list [catch {
gets $sock1
} msg] $msg
} {0 {Test 1}}
}
test serial-1.0.1 {peek serial} {
fconfigure $sock1 -blocking 0
read $sock1
} {}
fconfigure $sock1 -blocking 1
close $sock1
} else {
puts stdout "*** Skipping serial send/recv tests..."
}