locked
Serial Port I/O- error, when calling open() RRS feed

  • Question

  • I'm trying to read a line from a serialport (COM3) with readline. I use a adapter USB->SERIAL. The serialport constant push gps-data. The problem is that I can´t call open(). 

    code:

    PS> [System.IO.Ports.Serialport]::getportnames()
    
    PS> $port= new-Object System.IO.Ports.SerialPort COM3,4800,None,8,one
    
    PS> $port.DtrEnable = 'true'
    
    PS> $port.RtsEnable = 'true'
    
    PS> $port.Open()

    output:

    COM3
    
    
    Exception calling "Open" with "0" arguments(s): "The I/O operation has been suspended because a thread has been terminated or a program has requested it"
    
    

    no problem in command prompt (cmd) to type port:

    TYPE COM3

    type-command output the gps-data.

    someone how has experience of the problem?

    Wednesday, July 5, 2017 10:23 AM

All replies

  • The COM port is in use.  YOu also have a bad call:

    $port= new-Object System.IO.Ports.SerialPort('COM3',4800,'None',8,'one')

    You must quote strings.



    \_(ツ)_/

    Wednesday, July 5, 2017 10:45 AM