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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Serial Communication (Loopback)

Serial Communication (Loopback)

Scheduled Pinned Locked Moved C#
question
5 Posts 2 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.
  • C Offline
    C Offline
    Cadence2 0
    wrote on last edited by
    #1

    Hey Everyone, I'm writing an app to test whether a serial port on a computer will work correctly and I'm using the principle of serial loopback. I'm using the SerialPort class from System.io.ports and using a serial port object to write to the port and then listen to see if there was any data recieved. However, I always get a timeout for the recieve portion, even when I put the recieve method into a Thread. Any ideas what I should try? Thanks in advance -Karthik

    L 1 Reply Last reply
    0
    • C Cadence2 0

      Hey Everyone, I'm writing an app to test whether a serial port on a computer will work correctly and I'm using the principle of serial loopback. I'm using the SerialPort class from System.io.ports and using a serial port object to write to the port and then listen to see if there was any data recieved. However, I always get a timeout for the recieve portion, even when I put the recieve method into a Thread. Any ideas what I should try? Thanks in advance -Karthik

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Karthik Gaekwad wrote:

      I'm using the principle of serial loopback

      I don't think you can use a principle I think you have to actually have a loopback. :confused:

      "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
      Colin Angus Mackay in the C# forum

      led mike

      C 1 Reply Last reply
      0
      • L led mike

        Karthik Gaekwad wrote:

        I'm using the principle of serial loopback

        I don't think you can use a principle I think you have to actually have a loopback. :confused:

        "Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?"
        Colin Angus Mackay in the C# forum

        led mike

        C Offline
        C Offline
        Cadence2 0
        wrote on last edited by
        #3

        led Mike, You are correct. I am using loopback to solve the problem, but my recieve thread won't fire, even if I have the recieve wait for a message. Hope that clears it up. Any suggestions? -Karthik

        C 1 Reply Last reply
        0
        • C Cadence2 0

          led Mike, You are correct. I am using loopback to solve the problem, but my recieve thread won't fire, even if I have the recieve wait for a message. Hope that clears it up. Any suggestions? -Karthik

          C Offline
          C Offline
          Cadence2 0
          wrote on last edited by
          #4

          And the solution is.... After you write to the port using a serial port object, use the readExisting method. DO NOT CLOSE THE PORT and then OPEN the port again to read. There is nothing stored in the buffer at that point. I can be so dumb sometimes. That's what I get for trying to modularize my program.

          L 1 Reply Last reply
          0
          • C Cadence2 0

            And the solution is.... After you write to the port using a serial port object, use the readExisting method. DO NOT CLOSE THE PORT and then OPEN the port again to read. There is nothing stored in the buffer at that point. I can be so dumb sometimes. That's what I get for trying to modularize my program.

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            Nice work, thanks for posting the solution. :)

            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