在Windows 7上使用PowerShell从COM端口捕获输出

在Windows 7上使用PowerShell从COM端口捕获输出,windows,powershell,automation,port,powershell-2.0,Windows,Powershell,Automation,Port,Powershell 2.0,我想向COM端口发送Sierra AT命令,捕获输出并使用PowerShell将其存储在变量中 PowerShell版本: Name : ConsoleHost Version : 2.0 InstanceId : eb5987f0-9961-4842-b349-ba215d86fdfa UI : System.Management.Automation.Internal.Host.InternalHostUser

我想向COM端口发送Sierra AT命令,捕获输出并使用PowerShell将其存储在变量中

PowerShell版本:

Name             : ConsoleHost
Version          : 2.0
InstanceId       : eb5987f0-9961-4842-b349-ba215d86fdfa
UI               : System.Management.Automation.Internal.Host.InternalHostUserI
                   nterface
CurrentCulture   : en-IN
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
例如:
at!gstatus?

我试过了,但对我不起作用

PS> [System.IO.Ports.SerialPort]::getportnames()
COM16
PS> $port= new-Object System.IO.Ports.SerialPort COM16,115200,None,8,one
PS> $port.open()
PS> $port.WriteLine("at!gstatus?")
PS> $port.WriteLine("`r")
PS> $port.ReadExisting() //getting null output
PS> $port.close()
如何做到这一点?

调制解调器?通讯端口?在指挥部?是2015年还是1995年^_^

在读取数据之前尝试暂停:

$port = New-Object System.IO.Ports.SerialPort COM16,115200,None,8,one
$port.Open()

$port.WriteLine( "at!gstatus?" + "`r" )
Start-Sleep -m 50

$port.ReadExisting()
$port.Close()

来源:

您确定所有选项(
COM16115200,无,8,一)都是必需的且正确的吗?您是否尝试过其他(简单)命令?你是否尝试等待超过50毫秒?是的,选项是正确的。你说的简单命令是什么意思?你能提供吗?我等了50多秒。我是说其他AT命令可以和你的硬件一起工作。你的调制解调器是什么?我也试过其他命令。我能看到的是,当我发送命令时,它实际上正在发送,我可以在关闭端口并手动打开后看到命令输出。问题是我没有得到缓冲输出。我需要再等吗?还是必须做些别的事情?我正在使用sierra wireless WWAN Mode此脚本成功了多少次?