Skip to content

Commit

Permalink
Added clear_queue to the tcl library
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpeck committed Mar 21, 2024
1 parent 4bcfa46 commit 0835cc0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/tcladu.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ namespace eval tcladu {
}
return -1
}

proc clear_queue { index } {
# Clear the ADU100's output message queue
#
# Arguments:
# index -- Which ADU100 to target. 0,1,...(connected ADU100s -1)
set timeout_ms 10
set t0 [clock clicks -millisec]
foreach trial [iterint 0 10] {
set result [tcladu::read_device 0 8 $timeout_ms]
if {[lindex $result 0] == -7} {
# The device has timed out, so the queue is empty
return
}
}

}
}


2 changes: 1 addition & 1 deletion test/test.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ test_discovered_devices
test_serial_numbers
test_initializing_device

clear_queue 0
tcladu::clear_queue 0

# Reading and writing have to be done in pairs
test_writing_to_device
Expand Down

0 comments on commit 0835cc0

Please sign in to comment.