Asa safety I would allow a break out over time to make sure it does not LOCK into the loop and never let you out(reboot required). The following would let you out of the loop IF the Speed =0 OR if it timed out by 10 seconds.
SetOemDro(2050,0)
D0 while GetOemDro(39) > 0 OR GetOemDro(2050) < 9
SetOemDro(2050, GetOemDro(2050 +1)
Sleep(1000)
Loop
Just a thought, (;-) TP