473,779 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Read data from GSM modem

250 Contributor
I'm write code to read data from GSM modem. but it couldn't read modem response. Could you please help me? I'll post my code.
[PHP]using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using System.IO.Ports ;
using System.Threadin g;
using System.Timers;
using System.Diagnost ics;

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

public Form1()
{
InitializeCompo nent();
}

private void Form1_Load(obje ct sender, EventArgs e)
{

}

private void btn_Start_Click (object sender, EventArgs e)
{
sp.BaudRate = 19200;
sp.ReceivedByte sThreshold = 1;


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

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

private void btn_Write_Click (object sender, EventArgs e)
{
try
{
//Write line to serial port
//sp.Write(texSms .Text + "\r\n");
sp.Write(txt_Sm s.Text + "\r\n");
//texSms.Text = "";
txt_Sms.Text = "";
}
catch (System.Excepti on ex)
{
lblError.Text = ex.Message;
}
//Thread.Sleep(20 0);
//Set time delay
//System.Threadin g.Thread.Sleep( 30);
//sp.WriteTimeout = 200;
}

private void btn_Read_Click( object sender, EventArgs e)
{
try
{
//Cler text box
//Read serial port and displayed the data in text box
Thread current = Thread.CurrentT hread;
Thread.Sleep(10 00);
txt_Sms.Text = sp.ReadExisting ();
//texSms.Text = sp.ReadExisting ();
sp.Write("Conne cted" + "\nS");

}
catch (System.Excepti on ex)
{
lblError.Text = ex.Message;
}
}
}
}[/PHP]
Jun 4 '08 #1
1 3648
nmsreddi
366 Contributor
Hi

the code what you have written is almost correct, make sure that the baud rate you are using matches with the modem you are using .

are you able to get response from hyperterminal which proves that your modem is working fine .

as far as code is considered what you have used is correct ,better check other things connection cable and your hardware.


Regards
nmsreddi
Jun 6 '08 #2

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

Similar topics

4
3233
by: DraguVaso | last post by:
Hi, I'm experimenting with the Serial Port in VB.NET 2005. Although it isn't that easy to get any feedback from my COM-port as I thought it would be... How can I read all the Data that the port sends back? I tryed with SerialPort1.ReadLine, but that blocks the application and takes a lot of time (10 seconds!), I tryed SerialPort1.Read, but I have to read it into a buffer and has to indicate the count, but how do I know this?
3
1889
by: Taptu¶ | last post by:
Hi How can I retrieve data from modem ? For ex. I have established connection from dial-up and I want to get voice from modem and save it. Is it possible ? Taptu¶ -- http://www.studio-spider.com http://czarter.studio-spider.com
1
1519
by: RD | last post by:
I had an app in VB 6 that was being used to receive data automatically from callers using a modem - not via the internet, via dedicated phone lines. I now need to do the same thing but using .Net managed code using VB.NET. Can anyone point me to sample code on how to do this? I would also like to be able to use multi-modems ie a modem that has built-in connections for several phone lines. I don't even know where to find these, does...
17
3371
by: Franc Zabkar | last post by:
My D-Link DSL-302G modem/router has a real-time clock whose settings are volatile. To avoid hand keying the date/time via the modem's JS interface, I wonder if there is a way to copy the JS code to the hard drive and modify it to automatically retrieve the PC's date/time. I could then add the hacked JS page to my browser's bookmarks. I've already successfully modified and adapted other modem menus, but I don't know how to go about this...
0
1980
friendjin
by: friendjin | last post by:
VC++.NET I am going to read some response from serialport after I write some into serial port(serial port connected to the Modem). Now, when I connect, the code is working well. the problem is: once I disconnect the modem, the process will be dead, the reason is ReadFile command can not get the response from the modem. But I do not know how it can exist if there is no response. thanks
4
2061
by: Epictitus | last post by:
I am trying to write a script which will allow me to read the contents of an HTTP web page into memory, parse the data, and output a calculated value. The HTTP page is on a web enable appliance - I am reading some data out of a table for further calculation. I can't modify the web appliance, only read the text data. I've written a script on my Windoze PC that successful uses a MSXML2 ActiveX object to read the contents of a web page...
0
1538
by: daikeechi | last post by:
hello guys .. i want to perform pc to pc chatting via null modem cable.. i managed to write and sent data to serial port but how to write loops to read data from serial port ? i'm using visual c++ 2005 express editon .. below is my code .. #pragma endregion public: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { String^ msg;
1
1752
by: ghjk | last post by:
I'm writing code to read sms from GSM modem. When sms received to the modem I get +CMTI:"SM",15. So now i want to take only "15" from this message and send this number with the at command to read the sms. How can i do that? How can i extract only the "15"? Please help me. I'm using c#.
0
2072
by: veron | last post by:
hi. i want to send a sms to activate a device to open or close. can i use vb6 to write code to read sms from GSM modem? and how to use vb6 to write code to read sms from GSM modem?
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.