Handshaking With Device

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Matt Bloomfield Matt Bloomfield 7 months, 2 weeks ago.

  • Author
  • #57364
    Profile photo of Richard

    Serial COM port communication works great on all my devices except one. None of them use handshaking and I can't get the one that requires handshaking to work. Am I setting this up correctly? Right now I'm just using the following commands

    $port=new-object system.io.ports.serialport COM5, 9600, None, 8, one

    But it gives the following error

    Exception calling "Open" with "0" argument(s): "Access to the port 'COM5' is denied."
    At line:1 char:11
    + $port.open < <<< ()
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DotNetMethodException

    I can use software or hardware handshaking on the device. Right now I am trying to use the software handshaking option, but it isn't working. Can anyone tell me what I'm doing wrong? Thank you for your time!

  • #57467
    Profile photo of Matt Bloomfield
    Matt Bloomfield

    Is something else using the port?

    If you run

    $port=new-object system.io.ports.serialport COM5, 9600, None, 8, one
    $port2=new-object system.io.ports.serialport COM5, 9600, None, 8, one

    You get the same access denied error when you call the open() method on port 2. This would imply that something is already using the port. You should be able to check with WMI by querying the IsBusy value:

    Get-WmiObject Win32_SerialPortConfiguration -Filter 'Caption = "COM5"' | Select IsBusy

    If that returns true something else is using COM5.

You must be logged in to reply to this topic.