473,466 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Read sms using serial port communication in c#

250 Contributor
I want to read sms from GSM modem using C# in serial communication. I wrote the code. But i want to do it automatically. I put my code here and please tell me how can i do it automatically.

[PHP] public partial class SMS : Form
{

//create an Serial Port object
SerialPort sp = new SerialPort();

public SMS()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void btnStart_Click(object sender, EventArgs e)
{
sp.BaudRate = 19200;


try
{
//Open serial port
sp.PortName = "COM1";
sp.Open();

}
catch (System.Exception ex)
{
lblError.Text = ex.Message;
}
}

private void btnWrite_Click(object sender, EventArgs e)
{

try
{

//Write line to serial port
sp.WriteLine(texSms.Text + "\r");
texSms.Text = "";
sp.DiscardInBuffer();

}
catch(System.Exception ex)
{
lblError.Text = ex.Message;
}

//Set time delay
//System.Threading.Thread.Sleep(30);
// sp.WriteTimeout = 200;


}



private void btnRead_Click(object sender, EventArgs e)
{
try
{
//Cler text box

//Read serial port and displayed the data in text box
texSms.Text = sp.ReadLine();
//sp.Write("Connected" + "\n");

}
catch (System.Exception ex)
{
lblError.Text = ex.Message;
}

}


private void SMS_formClosing(object sender, FormClosingEventArgs e)
{
MessageBox.Show("Do u want to Close the App");
sp.Close();
}

private void btnStop_Click(object sender, EventArgs e)
{
texSms.Text = "";
sp.Close();
}


}[/PHP]
May 9 '08 #1
0 4533

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: collinm | last post by:
hi we use linux and c language under bash i do echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS2 that send command to a led display (alpha sign communication)
3
by: collinm | last post by:
hi i send a command to a led display, the led display is suppose to return me some character i write a string on a serial port void ledDisplayExist() { char msg={'\0', '\0', '\0', '\0',...
7
by: Michael Chong | last post by:
I wrote a program that communicate with SerialComm. In every 300 milliseconds, my program continuously send & receive data via the serial port once the program starts. My program is once in a...
4
by: Ben Zhu | last post by:
I have a small project, which need use both RS232 port and excel for data plot. I considering use excel VB macro for the entire project. Although I used serial port extensively in MFC, I am not...
6
by: Casey Bralla | last post by:
I'd like to read ASCII data from a serial port, but (once again) I'm having trouble getting started. (Can't seem to find the basic level of docs to get going <sigh>) I'd like to use only...
15
by: xkenneth | last post by:
Hi, I'm writing a couple python applications that use the serial port (RS-232) quite extensively. Is there any way I can monitor all activity on the serial port and have it printed as the...
4
by: rowan | last post by:
I'm writing a driver in Python for an old fashioned piece of serial equipment. Currently I'm using the USPP serial module. From what I can see all the serial modules seem to set the timeout when...
2
by: Adrian Chen | last post by:
please help me! I come across a problem. Now I develop a finger print management system which is based on B/S.When users click a button in the web pages, a device connected to the COM1 serial port...
4
by: Adrian Chen | last post by:
please help me! I come across a problem. Now I develop a finger print management system which is based on B/S.When users click a button in the web pages, a device connected to the COM1 serial port...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.