Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Serial Port communication

Serial Port communication

Scheduled Pinned Locked Moved C#
questioncsharpcom
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    t_nedelchev
    wrote on last edited by
    #1

    Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance

    D B H 3 Replies Last reply
    0
    • T t_nedelchev

      Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      Reposting is considered rude - please don't do it, it was only 17 hours ago you asked the same question which I have just responded to. (Maybe you should add no-reposting to the guidelines Chris?) Here[^]

      Dave

      1 Reply Last reply
      0
      • T t_nedelchev

        Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance

        B Offline
        B Offline
        Bekjong
        wrote on last edited by
        #3

        It's a bit of an odd scenario since real serial ports don't tend to disappear, and it doesn't seem this possibility was taken into account when Microsoft wrote the SerialPort class: There's no event that indicates Com-port "disappearance" in it. I guess your best option would be to start a separate thread that polls SerialPort.IsOpen every now and then: Most likely this will throw the error you got earlier when you disconnect the USB adapter, so you can catch that to see if the port's still there... Of course, you'll need to catch it at any other reference to SerialPort as well, that's just decent programming. Alternatively, there might be a class somewhere in the .Net framework that monitors USB devices, don't have any experience with that. Could very well be a p/invoke kind of thing.

        Standards are great! Everybody should have one!

        1 Reply Last reply
        0
        • T t_nedelchev

          Hello everybody My project is a C# project on VS2005. My application communicate with external device through Serial Port.I'm using USB to RS converter whitch add another COM Port in my computer.When I connect with device through this COM Port(transmit and receive data) everythink is OK.When unplug the USB cable from PC COM Port is still open and I try to transmit data the program is generate exception(Access to the Port is denied).How can I detect when the COM Port is disappear? Thanks in advance

          H Offline
          H Offline
          Himansu Sekhar Nayak
          wrote on last edited by
          #4

          I Need Some Code For Detecting Seriao Port As COM post Of My System. But Every where written in .Net2.0 Serialport.Port name space is used but iam develope my project in .Net1.1 then plaese Help ME Thanks In Advance

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups