使用Putty / Plink将命令发送到蓝牙串行

时间:2015-12-23 22:26:23

标签: batch-file bluetooth arduino putty plink

我在这里搜索了一些帖子,但我找不到一个我正在寻找的帖子。简单来说,我试图通过蓝牙自动向我的Arduino发送一个角色。

我尝试了Putty和Plink,但都没有自动完成。这是我到目前为止尝试的命令:

command.bat | putty -serial com3 -sercfg 9600

Command.bat:

@echo off
timeout /t 5
echo 2

plink -load Arduino echo 2

这会连接到Arduino上的蓝牙适配器,但会打开交互式控制台。我可以在键盘上按下它正确发送它的数字2。但是我希望自动发送。我有timeout因为连接蓝牙需要几秒钟。

有没有办法做到这一点所以我可以运行一个bat文件让它自动发送命令?

1 个答案:

答案 0 :(得分:0)

如果交互式控制台打开并且是最新的项目,您可以在交互式控制台启动时使用以下代码...

@if (@CodeSection == @Batch) @then
@echo off
set SendKeys=CScript //nologo //E:JScript "%~F0"

rem wait for interactive console to appear before pressing 2 to initialize
timeout /t 5    
%SendKeys% "{2}"

goto :EOF

@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));

如果你愿意,可以将它称为廉价修复,代码将调用javascript为你按2。我不知道如何将它与您的绝对程序联系起来,但这将自动运行,因为计算机将为您模拟输入。