首页 > 解决方案 > 为什么我从 Powershell 脚本写入串口后无法读取串口上的内容?

问题描述

这是我的代码简化:

> [System.IO.Ports.SerialPort]::getportnames() #to get all the port names 
COM1
COM2
COM3
$port = new-Object System.IO.Ports.SerialPort "COM1",9600,None,8,one
$port.Open()
$port.Write("Hey")
Start-Sleep -Milliseconds 3000 #I wait to make sure it gets written
$port.ReadExisting()

什么都没有返回。

当它应该返回“嘿”时,为什么它什么也不返回?我怎样才能正确地在端口上写入并读取它?

标签: powershellserial-port

解决方案


推荐阅读