简体   繁体   English

即使使用flushrecv,等待和等待也只能工作一次

[英]Wait and waitln only work once even when using flushrecv

I am writing a macro for Tera Term to test a microcontroller that is connected to a COM port. 我正在为Tera Term编写一个宏来测试连接到COM端口的微控制器。 I want the macro to pause and wait for a user prompt, but when I use a wait command it works for the first prompt, but does not work for the second prompt. 我希望宏暂停并等待用户提示,但是当我使用wait命令时,它适用于第一个提示,但不适用于第二个提示。

I have tried to use different keys, CR, F1, even alpha keys to trigger the prompt, but it won't wait at all. 我试图使用不同的键,CR,F1,甚至是alpha键来触发提示,但它不会等待。

clearscreen 0
dispstr 'INSTRUCTIONS_1'
dispstr #13
flushrecv
dispstr 'INSTRUCTIONS_2'
wait #13
flushrecv

sendln 'COMMAND_1'
mpause 250
sendln 'COMMAND_2'
mpause 250
sendln 'COMMAND_3'
mpause 250
sendln 'COMMAND_4'

dispstr 'INSTRUCTIONS_3'
wait #13
flushrecv

sendln 'COMMAND_5'
sendln 'COMMAND_6'

dispstr 'INSTRUCTIONS_4'
wait #13

I expect the macro to display instructions for someone doing the testing in the future, then hit enter once they have performed the instructions. 我希望宏能够显示将来进行测试的人员的指令,然后在他们执行指令后点击输入。 The commands are issued to the microcontroller and then the microcontroller does its thing while the macro waits for the user to connect things like an oscilloscope or a continuity checker. 这些命令发给微控制器,然后当宏等待用户连接诸如示波器或连续性检查器之类的东西时,微控制器完成它的工作。 The mpause commands are there to give the microcontroller a bit of time to write to memory and to execute the command. mpause命令用于给微控制器一些时间来写入存储器并执行命令。

What actually happens is the first two sets of instructions show up and wait for a carriage return. 实际发生的是前两组指令出现并等待回车。 Then the rest of the macro runs without pausing. 然后宏的其余部分运行而不会暂停。

EDIT: I found a workaround using yesnobox and message box instead of waiting for a keystroke. 编辑:我发现使用yesnobox和消息框的解决方法,而不是等待击键。

As far as I understand it, the wait command is just for what appears in the terminal screen. 据我所知,wait命令仅适用于终端屏幕中显示的内容。 So if the instructions have a carriage return in them, the wait command will execute because it has received the carriage return, depending on how quickly or synchronously it processes with the dispstr command. 因此,如果指令中有回车符,则wait命令将执行,因为它已收到回车符,具体取决于它使用dispstr命令处理的速度或同步程度。

The yesnobox would be a good workaround, but if the people are reading the instructions, I'd be curious if you couldn't just add a short pause (2-3) seconds after your dispstr commands and prior to your wait commands. yesnobox将是一个很好的解决方法,但如果人们正在阅读说明,我会好奇你是否不能在你的dispstr命令之后和等待命令之前添加一个短暂的暂停(2-3)秒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM