Hi friends
I am working on c#.net . i am developing a windows application using c# 2003
aim of my application is sending and receiving sms using GSM modem.
for this i am using AxMscomm control which is there in VB6.0(telephone device)
by using this i am able to receive the data and able to send message .but the
problem is when i send the sms and after sending if i want to receive the data again
it throwing an exception Exception from HRESULT:0x800A1F45
I am using two different windows for receiving (reading messages from sim) and
other for sending sms.
i am unable to access the AxMscomm open and close (ie portopen and close)
property from other windows forms .when i tried to close the port from other
windows form(form other than the AxMscomm control is placed) it shows the
portopen property as false but internally the connection is not closed.
how to handle the properties of this control from overall my application
My partil code goes like this....
******************************************code**** ********************
SerialPort is the name of my AxMscomm control
SerialPort.CommPort=1;
if(SerialPort.PortOpen)
SerialPort.PortOpen=false;
SerialPort.RThreshold=1;
SerialPort.Settings="9600,n,8,1";
SerialPort.DTREnable=true;
SerialPort.RTSEnable=true;
SerialPort.Handshaking=MSCommLib.HandshakeConstant s.comNone;
SerialPort.InputMode=MSCommLib.InputModeConstants. comInputModeText;
SerialPort.InputLen=0;
SerialPort.NullDiscard=false;
opening the connection to rs232.............
SerialPort.PortOpen=true;
timer1.Start();
////i am using timer to read messages ffrom my sim contineously
and stop reading when i tried to send the sms. and autmatically start reading
with out manual interaction.
reading messages from sim in timer tick
SerialPort.OnComm +=new EventHandler(SerialPort_OnComm);
try
{
timer1.Stop();
if(SerialPort.InBufferCount>0)
{
Thread.Sleep(1000);
ProcessSerialportdata((string) SerialPort.Input);
timer1.Start();// commented
}
else
timer1.Start(); //commented
}
catch(Exception ex)
{
if(timer1.Enabled==true)
timer1.Stop();
else
timer1.Start();
}
private void ProcessSerialportdata(string input)
{ richTextBox1.Text="";
richTextBox1.AppendText(input+"\n");
r
if(richTextBox1.TextLength>60)
{
i=0;
j++;
}
else if((s.IndexOf("ERROR")!=-1))
{
j=1;
// timer1.Start();
SerialPort.InBufferCount=0;
}
Sending sms.................
timer1.Stop();
string cmdsend="AT+CMGS="+"xxxxxxxxxx"+Convert.ToChar(13) ;
SerialPort.Output=cmdsend;
Thread .Sleep (100);
string cmd=SerialPort.Input.ToString ();
cmdsend="";
if(cmd.IndexOf (">")>1)
{
//cmd="";
cmdsend=" sms to b send"+Convert.ToChar (26);
SerialPort.Output =cmdsend;
Thread.Sleep (10000);
cmd=SerialPort.Input.ToString ();
}
Thread.Sleep(1000);
timer1.Start();
this is the code i am using in my application
i am using timer control to my control process of reading and sending
separately using single rs232 port
Hope you will get the best
Thanks and regards
Nmsreddi