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. How to Communicate with SerialPort Use C# Programming?

How to Communicate with SerialPort Use C# Programming?

Scheduled Pinned Locked Moved C#
csharpdotnettutorialquestion
6 Posts 3 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.
  • S Offline
    S Offline
    skywen
    wrote on last edited by
    #1

    Can C# Control Serial Port? Which class in .NET Framework is for SerialPort Communicate Programming? thanks a lot.

    C 1 Reply Last reply
    0
    • S skywen

      Can C# Control Serial Port? Which class in .NET Framework is for SerialPort Communicate Programming? thanks a lot.

      C Offline
      C Offline
      Corinna John
      wrote on last edited by
      #2

      For low level communication you can write to the virtual file "COM1".

      S 1 Reply Last reply
      0
      • C Corinna John

        For low level communication you can write to the virtual file "COM1".

        S Offline
        S Offline
        skywen
        wrote on last edited by
        #3

        Dear Corinna John Can you explain for detail how to write to the virtual file "COM1" in c#? Thanks a lot!

        C 1 Reply Last reply
        0
        • S skywen

          Dear Corinna John Can you explain for detail how to write to the virtual file "COM1" in c#? Thanks a lot!

          C Offline
          C Offline
          Corinna John
          wrote on last edited by
          #4

          Usually you open a file with the name of the serial port (COM[x]). The file doesn't exist in the file system. Whatever you write to the "file" will be sent to the serial port, messages from the device can be read from that virtual file. //open serial port COM1 FileStream fs = new FileStream("COM1", FileMode.OpenOrCreate); //sending data to the port it like writing them to a file fs.Write(...); fs.Flush(); It worked with other languages, I think it should also work with .NET

          E 1 Reply Last reply
          0
          • C Corinna John

            Usually you open a file with the name of the serial port (COM[x]). The file doesn't exist in the file system. Whatever you write to the "file" will be sent to the serial port, messages from the device can be read from that virtual file. //open serial port COM1 FileStream fs = new FileStream("COM1", FileMode.OpenOrCreate); //sending data to the port it like writing them to a file fs.Write(...); fs.Flush(); It worked with other languages, I think it should also work with .NET

            E Offline
            E Offline
            eggie5
            wrote on last edited by
            #5

            Can you do that with (LPT1)? /\ |_ E X E GG

            C 1 Reply Last reply
            0
            • E eggie5

              Can you do that with (LPT1)? /\ |_ E X E GG

              C Offline
              C Offline
              Corinna John
              wrote on last edited by
              #6

              As far as I know, you can do that with every port.

              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