Windows 10 error in opening serial port with Powershell

  • Thread starter Thread starter Francois Bondu
  • Start date Start date
F

Francois Bondu

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


>> $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
+ $port.open()
+ ~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : IOException



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 :

Continue reading...
 
Back
Top