【发布时间】:2011-08-27 22:34:41
【问题描述】:
我正在编写一个expect 脚本来自动化/dev/ttyUSB0 上的arduino 和本地telnet 端口6789 上的xine 实例之间的通信。如果在arduino 上检测到按键,它将通过它的串行发送一条线输出,button 01 pressed,button 2 pressed 等等。现在,根据按下的按钮,我想告诉xine 开始播放某些电影。
到目前为止,两种通信都是独立工作的,但我需要使用 telnet 消息对 arduino 消息做出反应,就像这个例子:
User presses key 1.
arduino sends serial line "button 01 pressed"
expect sees this string on /dev/ttyUSB0 and sends "playlist delete all; mrl add movie01.mp4" to xine.
xine then plays this movie while I am asking it for it's status every second.
Once the movie is finished playing, I tell xine to start the "loop" movie and also the arduino to set every output to the idle state.
所以,基本上我要求两种spawn同时进行通信(一个串行,一个远程登录),expect在它们上使用不同的字符串并以编程方式对它们做出反应(而最后一部分,以编程方式反应,已经完成)。
感谢您的帮助,
Christian.
【问题讨论】: