473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Reading sms from GSM modem using c#

250 100+
I'm trying to read sms from GSM modem using c#. my code is only working for at command. When I enter at+cmgr=1 it says"ERROR". but when i typr it hyperterminal. It is working.Could you please tell me what's wrong. I'm posting my code here.
[PHP]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;

namespace Rainfall
{
public partial class Form1 : Form
{
//create an Serial Port object
SerialPort sp = new SerialPort();

public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{

}

private void btnStart_Click(object sender, EventArgs e)
{
sp.BaudRate = 19200;
sp.WriteBufferSize = 1024;
try
{
//Open serial port
sp.PortName = "COM3";
sp.Open();
//sp.Write("Connected" + "\n");
}
catch (System.Exception ex)
{
lblError.Text = ex.Message;
}
}

private void btnWrite_Click(object sender, EventArgs e)
{
try
{
//Write line to serial port

string s = txtSMS.Text + "\r";
//sp.WriteLine("at+CMGR=1\r");
sp.Write(s);
txtSMS.Text = "";
}
catch (System.Exception ex)
{
lblError.Text = ex.Message;
}
}

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

txtSMS.Text = "";
//Read serial port and displayed the data in text box
//txtSMS.Text = sp.ReadLine();

txtSMS.Text = sp.ReadExisting();

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

private void btnStop_Click(object sender, EventArgs e)
{
txtSMS.Text = "";
sp.Close();
}
}
}
[/PHP]
Jun 10 '08 #1
1 11489
Plater
7,872 Expert 4TB
Is that following the correct modem sequencing commands for your device?
A lot of devices require a switch to "command mode" first (+++ ?)
Also, does hyperterminal send chacaters with a time pause in between them?
Jun 10 '08 #2

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

Similar topics

1
by: Ashish | last post by:
I wanted to make a Java application which would dial a telephone number using the modem. When the person on the other end lifts up the telephone (answers the phone), the application should start...
1
by: Ashish | last post by:
Hi, I was trying to make a out going call through the voice modem, play a audio file and disconnect. With the XTAPI implementation of the JTAPI I am able to do it with an analog phone line. The...
2
by: Etienne Labuschagne | last post by:
Assuming the modem is on COM5: m = open('COM5','wb+') m.write('+++\r\n') m.flush() m.write('ATQ0V1E0\r\n') m.flush() m.write('ATDT5551234;\r\n') m.flush() response = m.read()
1
by: Etienne Labuschagne | last post by:
Thanks for the responses. I will look into using PySerial for talking to the modem as suggested by Peter. The code example I gave is probably not the best way to do it, but it seemed to work ok...
28
by: MLH | last post by:
Would like to roll out something in Access 2.0 to read MAC address on 16-bit systems. Have resolved on 32-bit platforms but still need help with Access Basic code to do it from within Access 2.0.
3
by: Arne Beruldsen | last post by:
How do you read the serial number to a hard drive? Thanks...Arne
8
by: stephane8 | last post by:
I'm able to open and read my .csv file. But when the character "-" is in one of my fields (ex : 18802-002) I get a system.DBNull value ! Even if I edit the file with notepad and put "18802-002" I...
0
by: bishnu12 | last post by:
Hi all, There are two questions 1. I am trying to write a programme which can query to a modem get the modem details. i am using normal send() and recv() functions. But when i try to fetch a...
0
by: coaxfiber | last post by:
Hello, I have problem using dial-up connection with Fedora. My modem is not detected by the system.I have tried to install some drivers (*.tar) but didn't work.I'm not sure if this modem is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.