Sounds like the port isn't visible. Get the port names first and make sure the COM3 port shows up.
[System.IO.Ports.SerialPort]::GetPortNames()
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have installed a plug-and-play measurement instrument, with a USB terminal, and it appears as a serial COM port.
In windows device manager, COM3 is the only port.
with properties / main tab, the status says that the device works properly.
I want exchange API commands via powershell. There is an error at the open() step.
Could you help?
Thanks
Powershell (with administrator rights) commands
> $port= new-Object System.IO.Ports.SerialPort COM3,9600,None,8,One
> $port.NewLine = '\r'
> $port.ReadTimeout = 100
> $port.WriteTimeout = 100
> Start-Sleep -Milliseconds 100
> $port.open()
> Start-Sleep -Milliseconds 100
> $port
COM3
Exception lors de l'appel de « Open » avec « 0 » argument(s) : « Paramètre incorrect.
»
Au caractère Ligne:7 : 1
BaseStream :
BaudRate : 9600
BreakState :
BytesToWrite :
BytesToRead :
CDHolding :
CtsHolding :
DataBits : 8
DiscardNull : False
DsrHolding :
DtrEnable : False
Encoding : System.Text.ASCIIEncoding
Handshake : None
IsOpen : False
NewLine : \r
Parity : None
ParityReplace : 63
PortName : COM3
ReadBufferSize : 4096
ReadTimeout : 100
ReceivedBytesThreshold : 1
RtsEnable : False
StopBits : One
WriteBufferSize : 2048
WriteTimeout : 100
Site :
Sounds like the port isn't visible. Get the port names first and make sure the COM3 port shows up.
[System.IO.Ports.SerialPort]::GetPortNames()
Hi,
The serial port could be already in use. You can check with the WMI class Win32_SerialPortConfiguration.
Get-WmiObject -Class Win32_SerialPortConfiguration -Filter 'Caption = "COM3"' | Select-Object -Property IsBusy
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.