92 lines
3.7 KiB
Tcl
Executable File
92 lines
3.7 KiB
Tcl
Executable File
#!/usr/bin/env tclsh
|
|
source streamtestlib.tcl
|
|
|
|
# Define records, protocol and startup (text goes to files)
|
|
# The asynPort "device" is connected to a network TCP socket
|
|
# Talk to the socket with send/receive/assure
|
|
# Send commands to the ioc shell with ioccmd
|
|
|
|
set records {
|
|
record (bo, "DZ:percent")
|
|
{
|
|
field (DTYP, "stream")
|
|
field (OUT, "@test.proto percent device")
|
|
}
|
|
record (ao, "DZ:ao")
|
|
{
|
|
field (DTYP, "stream")
|
|
field (OUT, "@test.proto ao device")
|
|
field (EOFF, "-10")
|
|
field (ESLO, "0.000305180437934")
|
|
field (LINR, "LINEAR")
|
|
}
|
|
record (longout, "DZ:lo")
|
|
{
|
|
field (DTYP, "stream")
|
|
field (OUT, "@test.proto lo device")
|
|
}
|
|
record (longout, "DZ:bcd")
|
|
{
|
|
field (DTYP, "stream")
|
|
field (OUT, "@test.proto bcd device")
|
|
}
|
|
}
|
|
|
|
set protocol {
|
|
Terminator = LF;
|
|
percent {out "\%\x25\37\045" 0x25 37 045;}
|
|
ao {out "%.2f %.2e %.2E %.2g %.2G %i %d %u %o %04x %#.2f %#.2e %#.2E %#.2g %#.2G %#i %#d %#u %#o %#06x";}
|
|
lo {out "%d %(VAL)d %06d %x %06X %b %06b %.6b %B.! %06B.!";}
|
|
bcd {out "%D %6D %.2D %.4D %.6D %.8D %#D %#6D %#.2D %#.4D %#.6D";}
|
|
}
|
|
|
|
set startup {
|
|
}
|
|
|
|
set debug 0
|
|
|
|
startioc
|
|
|
|
# Some formats give different results on 32 bit and 64 bit machines.
|
|
# This occurs when printing negative numbers with unsigned formats.
|
|
# This is normal. E.g. -1 HAS a different number of 1 bits.
|
|
# Specify the width field in the format if this is a problem.
|
|
|
|
ioccmd {dbpf DZ:percent 1}
|
|
assure "%%%%%%%\n"
|
|
ioccmd {dbpf DZ:ao 0}
|
|
assure "0.00 0.00e+00 0.00E+00 0 0 32767 32767 32767 77777 7fff 0.00 0.00e+00 0.00E+00 0.0 0.0 32767 32767 32767 077777 0x7fff\n"
|
|
ioccmd {dbpf DZ:ao 10}
|
|
assure "10.00 1.00e+01 1.00E+01 10 10 65535 65535 65535 177777 ffff 10.00 1.00e+01 1.00E+01 10. 10. 65535 65535 65535 0177777 0xffff\n"
|
|
ioccmd {dbpf DZ:ao -10}
|
|
assure "-10.00 -1.00e+01 -1.00E+01 -10 -10 0 0 0 0 0000 -10.00 -1.00e+01 -1.00E+01 -10. -10. 0 0 0 0 000000\n"
|
|
ioccmd {dbpf DZ:ao 1e-6}
|
|
assure "0.00 1.00e-06 1.00E-06 1e-06 1E-06 32768 32768 32768 100000 8000 0.00 1.00e-06 1.00E-06 1.0e-06 1.0E-06 32768 32768 32768 0100000 0x8000\n"
|
|
ioccmd {dbpf DZ:lo 0}
|
|
assure "0 0 000000 0 000000 0 000000 000000 . ......\n"
|
|
ioccmd {dbpf DZ:lo 12345}
|
|
assure "12345 12345 012345 3039 003039 11000000111001 11000000111001 111001 !!......!!!..! !!......!!!..!\n"
|
|
ioccmd {dbpf DZ:lo -1}
|
|
if {$tcl_platform(machine) == "x86_64"} {
|
|
assure "-1 -1 -00001 ffffffffffffffff FFFFFF 11111111111111111111111111111111 11111111111111111111111111111111 111111 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
|
} else {
|
|
assure "-1 -1 -00001 ffffffff FFFFFF 11111111111111111111111111111111 11111111111111111111111111111111 111111 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
|
|
}
|
|
ioccmd {dbpf DZ:lo -1234}
|
|
if {$tcl_platform(machine) == "x86_64"} {
|
|
assure "-1234 -1234 -01234 fffffffffffffb2e FFFB2E 11111111111111111111101100101110 11111111111111111111101100101110 101110 !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!. !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!.\n"
|
|
} else {
|
|
assure "-1234 -1234 -01234 fffffb2e FFFB2E 11111111111111111111101100101110 11111111111111111111101100101110 101110 !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!. !!!!!!!!!!!!!!!!!!!!!.!!..!.!!!.\n"
|
|
}
|
|
ioccmd {dbpf DZ:lo 255}
|
|
assure "255 255 000255 ff 0000FF 11111111 11111111 111111 !!!!!!!! !!!!!!!!\n"
|
|
ioccmd {dbpf DZ:lo 65535}
|
|
assure "65535 65535 065535 ffff 00FFFF 1111111111111111 1111111111111111 111111 !!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!\n"
|
|
ioccmd {dbpf DZ:bcd 1020304}
|
|
if {$tcl_platform(machine) == "x86_64"} {
|
|
assure "\0\0\0\0\1\2\3\4 \0\0\0\0\1\2\3\4 \4 \3\4 \2\3\4 \1\2\3\4 \4\3\2\1\0\0\0\0 \4\3\2\1\0\0\0\0 \4 \4\3 \4\3\2\n"
|
|
} else {
|
|
assure "\1\2\3\4 \0\0\1\2\3\4 \4 \3\4 \2\3\4 \1\2\3\4 \4\3\2\1 \4\3\2\1\0\0 \4 \4\3 \4\3\2\n"
|
|
}
|
|
finish
|