Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: To musefan Pin
Narendra Reddy Vajrala3-Apr-09 3:21
Narendra Reddy Vajrala3-Apr-09 3:21 
AnswerRe: To musefan Pin
N a v a n e e t h3-Apr-09 0:47
N a v a n e e t h3-Apr-09 0:47 
AnswerRe: To musefan Pin
Anthony Mushrow3-Apr-09 2:41
professionalAnthony Mushrow3-Apr-09 2:41 
Questionsms using sending and receiving GSM Modem Pin
rameshidiot3-Apr-09 0:16
rameshidiot3-Apr-09 0:16 
AnswerRe: sms using sending and receiving GSM Modem Pin
Mycroft Holmes3-Apr-09 0:30
professionalMycroft Holmes3-Apr-09 0:30 
AnswerRe: sms using sending and receiving GSM Modem Pin
Nagy Vilmos3-Apr-09 0:32
professionalNagy Vilmos3-Apr-09 0:32 
AnswerRe: sms using sending and receiving GSM Modem Pin
King Julien3-Apr-09 0:46
King Julien3-Apr-09 0:46 
GeneralRe: sms using sending and receiving GSM Modem Pin
joey_go25-Apr-10 0:21
joey_go25-Apr-10 0:21 
//  Written by  Joseph Goldburg  mobile  61 412 750 765  email  joe.g@optusnet.com.au<br />
// <br />
//  Version 0.1  beta only<br />
//<br />
//<br />
//  This Program takes a input text file GSM  AT commands and send them to the serial port<br />
//  command line options  are<br />
//<br />
// ConsoleApplication1  COMx  INPUT_FILE  LOG_FILE  PAUSE<br />
// Where<br />
//      COMx   is COM1 COM2 COM3 serial port etc<br />
//<br />
//      INPUT_FILE is the input AT text file name  file name but be 8.3 dos file format<br />
//<br />
//      LOG_FILE  text file for the log output file name must be 8.3 dos file format<br />
//<br />
//      PAUSE if any character  then the program will wait until keypress to exit<br />
//<br />
// Example calling the command line <br />
//<br />
//            ConsoleApplication1  COM1 AT.txt log.txt<br />
//<br />
// Example of INPUT_FILE  AT.txt  for sending SMS's<br />
//<br />
//      AT+CMGS="61412750765"<br />
//      Sending text messages is easy^z<br />
//      AT+CMGS="61412750765"<br />
//      Sending another SMS message^z<br />
//      AT+CMGS="61412750765"<br />
//      Yet another text message^z<br />
//      ATZ<br />
//<br />
// Any AT commands can be sent, jst add them to the text file<br />
//<br />
// Special consideration is given to ascii characters "^Z"  or "^z" these are turned in to ascii control characters<br />
// Baud rate fixed at 115200<br />
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.IO.Ports;<br />
<br />
namespace ConsoleApplication1<br />
{<br />
    class Program<br />
    {<br />
        static void Main(string[] args)<br />
        {<br />
            for (int i = 0; i < args.Length; i++)<br />
            {<br />
                System.Console.Write("Arg[{0}] = [{1}]     ", i, args[i]);<br />
            };<br />
            Console.WriteLine();<br />
            Console.WriteLine();<br />
            Console.WriteLine("Written by Joseph Goldburg Phone 0412 750 765  joe.g@optusnet.com.au");<br />
            Console.WriteLine();<br />
<br />
            if (args.Length < 3) <br />
            {<br />
                Console.WriteLine("*** Error in command line arguments ***\n");<br />
                Console.WriteLine("3 arguments required COMx inputfile logfile  [Pause]\n\n");<br />
<br />
                Console.WriteLine("Press any key to continue...");<br />
                Console.ReadKey(true);<br />
                <br />
                System.Environment.Exit(1); <br />
            }<br />
            <br />
            // 3 arguments  COM1 Input file  and output file<br />
            // files must be in dos compressed formant 8.3<br />
<br />
            // Arg[0] is the comport selection  comport<br />
            // Arg[1] is INPUT_FILE  inputfile <br />
            // Arg[2] is LOG_File<br />
            // Arg[3] Is pause<br />
<br />
            // Convert the \ in the args string to \\ for the correct sting<br />
            string comport = args[0].ToUpper();<br />
            string inputfile = args[1].Replace("\\", "\\\\");<br />
            string logfile  = args[2].Replace("\\", "\\\\");<br />
<br />
            //Console.WriteLine("This is the new {0}", args[1]);<br />
<br />
            <br />
            System.IO.StreamReader sr = new System.IO.StreamReader(inputfile);<br />
            System.IO.TextWriter tw = new System.IO.StreamWriter(logfile);<br />
            string line;<br />
            tw.WriteLine("Job Started {0} ", DateTime.Now);<br />
            Console.WriteLine("Job Started {0} ", DateTime.Now);<br />
<br />
<br />
            SerialPort port = new SerialPort(comport, 115200, Parity.None, 8, StopBits.One);<br />
            try<br />
            {  // try and open the serial port from the 1st argument args[0]<br />
<br />
                port.Open();<br />
                tw.WriteLine("Compport {0} open ",comport);<br />
                Console.WriteLine("Compport {0} open ", comport);<br />
<br />
                string ATstring = "AT";<br />
                string ATZstring = "ATZ";<br />
<br />
                int starttime = DateTime.Now.Second;<br />
                while (starttime == DateTime.Now.Second) { }<br />
                port.WriteLine(ATZstring); tw.WriteLine(ATstring); Console.WriteLine(ATstring); // AT<br />
                starttime = DateTime.Now.Second;<br />
                while (starttime == DateTime.Now.Second) { }<br />
<br />
<br />
                starttime = DateTime.Now.Second;<br />
                while (starttime == DateTime.Now.Second) { }<br />
                port.WriteLine(ATZstring); tw.WriteLine(ATZstring); Console.WriteLine(ATZstring); //ATZ <br />
                starttime = DateTime.Now.Second;<br />
                while (starttime == DateTime.Now.Second) { }<br />
                starttime = DateTime.Now.Second;<br />
                while (starttime == DateTime.Now.Second) { }<br />
<br />
                while ((line = sr.ReadLine()) != null)  // read string lines from test file<br />
                {<br />
                    if (line.IndexOf("^Z") > -1 || line.IndexOf("^z") > -1)  // search for Z^ or z^<br />
                    {<br />
                        line = line.Replace("^Z", "\x001A");   // Convert ASCII "^Z"  to real ^z<br />
                        line = line.Replace("^z", "\x001A");   // Convert ASCII "^z"  to real ^z<br />
                        port.Write(line); //  no <CR> <LF> as  ^z terminates string<br />
                        tw.WriteLine(line);<br />
                        Console.WriteLine("Control z reached : SMS is : -->  {0}",line);<br />
<br />
                        //port.Write(new byte[] { 0x0A, 0xE2, 0xFF }, 0, 3);<br />
                        <br />
                        starttime = DateTime.Now.Second;<br />
                        while (starttime == DateTime.Now.Second) { }<br />
                        starttime = DateTime.Now.Second;<br />
                        while (starttime == DateTime.Now.Second) { }<br />
                    }<br />
                    else<br />
                    {<br />
                        port.WriteLine(line); // send string line to serial port<br />
                        tw.WriteLine(line);    // send to log file <br />
                        Console.WriteLine(line); // send to console<br />
<br />
                        starttime = DateTime.Now.Second;<br />
                        while (starttime == DateTime.Now.Second) { }<br />
                    }<br />
                    <br />
                }<br />
                port.Close();<br />
            }<br />
            catch<br />
            {<br />
                Console.WriteLine("Could not open serial comport {0}", args[0]);<br />
            }<br />
<br />
            // If 4 or more arguments in the command line then wait until keypress<br />
            if (args.Length > 3)<br />
            {<br />
                Console.WriteLine("Press any key to continue...");<br />
                Console.ReadKey(true);<br />
            }<br />
<br />
<br />
          tw.Close();  // close LOG_FILE  logfile<br />
          sr.Close();  // close INPUT_FILE inputfile<br />
        }<br />
    }<br />
}<br />

GeneralRe: sms using sending and receiving GSM Modem Pin
King Julien27-Apr-10 18:36
King Julien27-Apr-10 18:36 
QuestionIComparer Issue Pin
AmitG773-Apr-09 0:10
AmitG773-Apr-09 0:10 
AnswerRe: IComparer Issue Pin
DaveyM693-Apr-09 0:14
professionalDaveyM693-Apr-09 0:14 
QuestionButton click in sub-dialog copy data onto main dialog Pin
Martin310882-Apr-09 23:56
Martin310882-Apr-09 23:56 
AnswerRe: Button click in sub-dialog copy data onto main dialog Pin
Mycroft Holmes3-Apr-09 0:34
professionalMycroft Holmes3-Apr-09 0:34 
AnswerRe: Button click in sub-dialog copy data onto main dialog [REPOST Do not respond!!] Pin
Henry Minute3-Apr-09 3:51
Henry Minute3-Apr-09 3:51 
Questionhow to get system date & Time using c#.net Pin
poonam jagdale2-Apr-09 23:15
poonam jagdale2-Apr-09 23:15 
AnswerRe: how to get system date & Time using c#.net Pin
musefan2-Apr-09 23:23
musefan2-Apr-09 23:23 
AnswerRe: how to get system date & Time using c#.net Pin
Narendra Reddy Vajrala2-Apr-09 23:45
Narendra Reddy Vajrala2-Apr-09 23:45 
GeneralRe: how to get system date & Time using c#.net Pin
musefan2-Apr-09 23:52
musefan2-Apr-09 23:52 
AnswerRe: how to get system date & Time using c#.net Pin
Christian Graus2-Apr-09 23:54
protectorChristian Graus2-Apr-09 23:54 
JokeRe: how to get system date & Time using c#.net Pin
musefan2-Apr-09 23:58
musefan2-Apr-09 23:58 
QuestionHow to Read a file from Application folder Pin
Narendra Reddy Vajrala2-Apr-09 23:04
Narendra Reddy Vajrala2-Apr-09 23:04 
AnswerRe: How to Read a file from Application folder Pin
Narendra Reddy Vajrala2-Apr-09 23:11
Narendra Reddy Vajrala2-Apr-09 23:11 
AnswerRe: How to Read a file from Application folder Pin
#realJSOP2-Apr-09 23:47
professional#realJSOP2-Apr-09 23:47 
GeneralRe: How to Read a file from Application folder Pin
Narendra Reddy Vajrala2-Apr-09 23:52
Narendra Reddy Vajrala2-Apr-09 23:52 
GeneralRe: How to Read a file from Application folder Pin
musefan2-Apr-09 23:54
musefan2-Apr-09 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.