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. communicating with serial port in C#

communicating with serial port in C#

Scheduled Pinned Locked Moved C#
csharptutorialquestionannouncement
8 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.
  • S Offline
    S Offline
    Sourie
    wrote on last edited by
    #1

    I want to work with serial port, I found a good example in this site. And I learnt a little about serial work in c#. But now I want to now how could I update serial port communication protocol in C##? Like; how could I change the value of serial port parameters: Parity, BaudRate, StopBits, DataBits ect. Thanks in advance

    Mansureh Shahraki Moghaddam

    L 1 Reply Last reply
    0
    • S Sourie

      I want to work with serial port, I found a good example in this site. And I learnt a little about serial work in c#. But now I want to now how could I update serial port communication protocol in C##? Like; how could I change the value of serial port parameters: Parity, BaudRate, StopBits, DataBits ect. Thanks in advance

      Mansureh Shahraki Moghaddam

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      you set serial port parameters thru the SerialPort class, use one of the constructors and/or one of several properties (such as SerialPort.BaudRate). :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Happy 2008!


      S 1 Reply Last reply
      0
      • L Luc Pattyn

        you set serial port parameters thru the SerialPort class, use one of the constructors and/or one of several properties (such as SerialPort.BaudRate). :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Happy 2008!


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

        Thank you so much for helping me. You mean like these codes: _serialPort.Open(); _serialPort.ReadTimeout = 5000; _serialPort.WriteLine("*cls"); But what about wiring? Is that enough to estanbish a "Null Modem" connection?

        Sourie

        S L 2 Replies Last reply
        0
        • S Sourie

          Thank you so much for helping me. You mean like these codes: _serialPort.Open(); _serialPort.ReadTimeout = 5000; _serialPort.WriteLine("*cls"); But what about wiring? Is that enough to estanbish a "Null Modem" connection?

          Sourie

          S Offline
          S Offline
          Sourie
          wrote on last edited by
          #4

          Hi again, I found this link. I think it could be helpful for me: http://www.codeproect.com/KB/cs/serialcommunication.asp

          Sourie

          1 Reply Last reply
          0
          • S Sourie

            Thank you so much for helping me. You mean like these codes: _serialPort.Open(); _serialPort.ReadTimeout = 5000; _serialPort.WriteLine("*cls"); But what about wiring? Is that enough to estanbish a "Null Modem" connection?

            Sourie

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Hi again. When you connect a peripheral to a PC, you typically need a straight cable with one male and one female connector. When you connect two PCs, you would need a null modem cable, which has two female connectors. There is nothing you can do about that in software, your cable must match the situation. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Voting for dummies? No thanks. X|


            S 1 Reply Last reply
            0
            • L Luc Pattyn

              Hi again. When you connect a peripheral to a PC, you typically need a straight cable with one male and one female connector. When you connect two PCs, you would need a null modem cable, which has two female connectors. There is nothing you can do about that in software, your cable must match the situation. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              Voting for dummies? No thanks. X|


              S Offline
              S Offline
              Sourie
              wrote on last edited by
              #6

              Thanks for your reply. Actually I want to connect an AVR MCU to PC. As I studied these days, I think I should make a NULL MODEM connection between AVR and Serial Port of PC (but by inserting a MAX232 chip). It means that RXD and TXD from PC should be connected to TXD and RXD of MCU and DTR of PC should be connected to its DSR and CD, also its RTS should be connected to CTS. I think this wiring is enough and after that I should write a C# code for Pc and an assembly code for MCU to communicate to eachother.

              Sourie

              L 1 Reply Last reply
              0
              • S Sourie

                Thanks for your reply. Actually I want to connect an AVR MCU to PC. As I studied these days, I think I should make a NULL MODEM connection between AVR and Serial Port of PC (but by inserting a MAX232 chip). It means that RXD and TXD from PC should be connected to TXD and RXD of MCU and DTR of PC should be connected to its DSR and CD, also its RTS should be connected to CTS. I think this wiring is enough and after that I should write a C# code for Pc and an assembly code for MCU to communicate to eachother.

                Sourie

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                Hi, yes, you need at least three wires: GND to GND RXD to TXD TXD to RXD you may want or need some of the control lines, depending on your application and port settings. If so, they need to be cross-wired too. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                Voting for dummies? No thanks. X|


                S 1 Reply Last reply
                0
                • L Luc Pattyn

                  Hi, yes, you need at least three wires: GND to GND RXD to TXD TXD to RXD you may want or need some of the control lines, depending on your application and port settings. If so, they need to be cross-wired too. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  Voting for dummies? No thanks. X|


                  S Offline
                  S Offline
                  Sourie
                  wrote on last edited by
                  #8

                  Thanks alot :)

                  Sourie

                  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