Serial Communication in C#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nmsreddi
    Contributor
    • Jul 2006
    • 366

    Serial Communication in C#.net

    HI,
    I am developing an application using C#.net2.0 FrameWork ,in which communication with GSM modem is mandatory.The main aim of my application is it should interact with GSM moden for sending messages and as well as receiving messages .Presently i am mscomm available in C#.net2.0 .the problem is i can just send the message to the serialport(RS-232) but unable to interact with the modem .
    Any suggestions Plz.
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    pls post you code segment in your next.. as that will be alot more easier to assist you.. we will help you to validate your code.. good luck my fren.. :)

    Comment

    • nmsreddi
      Contributor
      • Jul 2006
      • 366

      #3
      hi sashi,
      First thanks for ur support,i am giving my partial code regarding mscomm so that i may more benifit
      *************** **code********* ************
      private void InitComPort()
      {
      // Set the com port to be 1
      com.CommPort = 1;

      // This port is already open, close it to reset it.
      if (com.PortOpen) com.PortOpen = false;

      // Trigger the OnComm event whenever data is received
      com.RThreshold = 1;

      // Set the port to 9600 baud, no parity bit, 8 data bits, 1 stop bit (all standard)
      com.Settings = "9600,n,8,1 ";

      // No handshaking is used
      com.Handshaking = MSCommLib.Hands hakeConstants.c omNone;

      // Don't mess with byte arrays, only works with simple data (characters A-Z and numbers)
      com.InputMode = MSCommLib.Input ModeConstants.c omInputModeText ;



      // Read the entire waiting data when com.Input is used
      com.InputLen = 0;

      // Don't discard nulls, 0x00 is a useful byte
      com.NullDiscard = false;

      // Attach the event handler
      com.OnComm += new System.EventHan dler(this.OnCom m);

      // Open the com port
      com.PortOpen = true;
      }

      private void OnComm(object sender, EventArgs e) // MSCommLib OnComm Event Handler
      {
      // If data is waiting in the buffer, process it.

      if (com.InBufferCo unt > 0) ProcessComData( (string) com.Input);
      }

      private void ProcessComData( string input)
      {
      // Send incoming data to a Rich Text Box
      rtfTerminal.App endText(input + "\n");
      }

      many thanks
      msreddy

      Comment

      • nmsreddi
        Contributor
        • Jul 2006
        • 366

        #4
        serialcommunica tion using .Net

        HI,
        I am developing an application using C#.net2.0 FrameWork ,in which

        communication with GSM modem is mandatory.The main aim of my application is

        it should interact with GSM moden for sending messages and as well as

        receiving messages .Presently i am mscomm available in C#.net2.0 .the

        problem is i can just send the message to the serialport(RS-232) but unable

        to interact with the modem .
        Any suggestions Plz.

        with regards
        nmsreddy
        _______________ _______________ _______________ _______________ ______________
        hi sashi,
        First thanks for ur support,i am giving my partial code regarding mscomm so

        that i may more benifit
        *************** **code********* ************
        private void InitComPort()
        {
        // Set the com port to be 1
        com.CommPort = 1;

        // This port is already open, close it to reset it.
        if (com.PortOpen) com.PortOpen = false;

        // Trigger the OnComm event whenever data is received
        com.RThreshold = 1;

        // Set the port to 9600 baud, no parity bit, 8 data bits, 1 stop bit (all

        standard)
        com.Settings = "9600,n,8,1 ";

        // No handshaking is used
        com.Handshaking = MSCommLib.Hands hakeConstants.c omNone;

        // Don't mess with byte arrays, only works with simple data (characters A-Z

        and numbers)
        com.InputMode = MSCommLib.Input ModeConstants.c omInputModeText ;



        // Read the entire waiting data when com.Input is used
        com.InputLen = 0;

        // Don't discard nulls, 0x00 is a useful byte
        com.NullDiscard = false;

        // Attach the event handler
        com.OnComm += new System.EventHan dler(this.OnCom m);

        // Open the com port
        com.PortOpen = true;
        }

        private void OnComm(object sender, EventArgs e) // MSCommLib OnComm Event

        Handler
        {
        // If data is waiting in the buffer, process it.

        if (com.InBufferCo unt > 0) ProcessComData( (string) com.Input);
        }

        private void ProcessComData( string input)
        {
        // Send incoming data to a Rich Text Box
        rtfTerminal.App endText(input + "\n");
        }

        many thanks
        msreddy

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          How do you make the modem dial?
          What sort of messages are you sending to it?

          Having opened a port to a modem you should be able to interact with it using the Haynes command set (as extended for GSM/GPRS/3GPP modems).

          Comment

          • nmsreddi
            Contributor
            • Jul 2006
            • 366

            #6
            hi banfa
            i am using wavecom gsm modem ,i got succes doing it in VB6.0 by using mscomm object .In that modem i am my local network SIM (any provider) just we use in our mobile phone .But the only difference for modem works only for sending and receiving messages even for our mobile or any other similar device
            When comming to message formats it is related to our company device ,the message consists of 4 characters staring with # and ending with !.
            I think this information may guide u to understand my application


            withregards
            nmsreddi

            Comment

            • raju2003
              New Member
              • Sep 2006
              • 2

              #7
              Hai...
              Seems i also hav a problem regarding ur topic.
              I hope ur kind help....
              Im developing a software using C# to send SMS messages automatically. Really its a part of a building monitoring software.Im using a Ericsson T-10s for my task. I hav testet the phone with AT commands using hyper terminal. Dats fine...Nw how can i send AT commands to the phone via serial port using C# . My program should send SMS messages automatically..
              Hope ur support....
              Thanks..

              Comment

              • Banfa
                Recognized Expert Expert
                • Feb 2006
                • 9067

                #8
                Look up

                system.io.port

                Comment

                • nmsreddi
                  Contributor
                  • Jul 2006
                  • 366

                  #9
                  banfa

                  tanks for your response


                  but the problem system.io.ports

                  name space is not available in .Net1.1 version it is available from .Net2.0 on wards

                  ok any how thanks i am trying in .net2.0 also but but unable to intyeract with the modem the code which i have given previously is ,able to send data to buffer(rs-232 port ) but from i cannot communicate with the hardware

                  Hope you may respond soon


                  regards

                  nmsreddi

                  Comment

                  • raju2003
                    New Member
                    • Sep 2006
                    • 2

                    #10
                    Hey guys.......

                    Waiting for ur attention. Hope i would find some help frpm u guys. Thanks...
                    Im using visual studio 2005.

                    Comment

                    • kisnam
                      New Member
                      • Oct 2006
                      • 3

                      #11
                      Hi guys,

                      Im happy to see u ppl discussing on c# code to send SMS... I want to send Multimedia messages to mobile... for eg: images, video, r may include both.. how to set attributes in c#.net i may send and receive MMs thru my application (ofcourse developed in c#)....

                      Comment

                      • Mobeen
                        New Member
                        • Nov 2006
                        • 1

                        #12
                        Hi guyz
                        Can any one send me the complete source code for this application (SMS using C#.NET) ?

                        will b grateful to u...

                        desperately waiting 4 reply.

                        Regards

                        Mobeen

                        Comment

                        • willamike
                          New Member
                          • Aug 2007
                          • 2

                          #13
                          Hi, I think it is a lot of pain to program RS232 to send SMS messages and once the number of messages goes and you have to switch to IP SMS you have to do it again. A better solution is to use an SMS Gateway. This article gives information about C# SMS Gateway technology.

                          Comment

                          • cph05a
                            New Member
                            • Feb 2008
                            • 1

                            #14
                            I'm working with the Symbol MC35 (running windows mobile) and I'm attempting to read from the serial port using the SerialPort class in .NET. I've gotten my program to run properly my laptop, but it doesn't seem to work on the MC35. It finds the serial port and opens it successfully, but never seems to get any input. Does the MC35 support reading from the serial port?

                            Comment

                            • Rajeshshewale
                              New Member
                              • Aug 2007
                              • 8

                              #15
                              I have written code here, just check this link:
                              [Link Removed]

                              Comment

                              Working...