Skip to content

Commit 36e1cbc

Browse files
committed
clarify stream end arith
1 parent 858530a commit 36e1cbc

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

resources/external_control.urscript

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,13 @@ while control_mode > MODE_STOPPED:
11681168
thread_trajectory = run trajectoryThread()
11691169
elif params_mult[2] == TRAJECTORY_MODE_STREAM_END:
11701170
# params_mult[3] is the total count of spline points the producer
1171-
# wrote to the trajectory socket since STREAM_START. Convert the
1172-
# in-flight sentinel into the remaining unread count:
1173-
# M_consumed = STREAMING_SENTINEL - trajectory_points_left
1174-
# remaining = params_mult[3] - M_consumed
1175-
# = trajectory_points_left + params_mult[3] - STREAMING_SENTINEL
1176-
trajectory_points_left = trajectory_points_left + params_mult[3] - STREAMING_SENTINEL
1171+
# wrote to the trajectory socket since STREAM_START. The
1172+
# trajectoryThread has decremented trajectory_points_left once per
1173+
# consumed point starting from STREAMING_SENTINEL, so the consumed
1174+
# count is (STREAMING_SENTINEL - trajectory_points_left). The
1175+
# unread remainder still in the OS socket buffer is therefore
1176+
# the producer's total minus the consumer's consumed count.
1177+
trajectory_points_left = params_mult[3] - (STREAMING_SENTINEL - trajectory_points_left)
11771178
trajectory_streaming = False
11781179
elif params_mult[2] == TRAJECTORY_MODE_CANCEL:
11791180
textmsg("cancel received")

0 commit comments

Comments
 (0)