Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 19th, 2005, 01:59 PM
Registered User
 
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Modem: send commands, read answers

Hi,

I have to send some commands and read the modem's answers to those commands. The time the modem needs to answer the command varies depending on the command issued by the PC.

I have been working on a function like this:

answer = modemCommandAnswer("AT","OK");

private bool modemCommandAnswer(string modemCommand, string expectedAnswer)
{
string modemAnswer;

serialPortModem.WriteLine(modemCommand);
modemAnswer = serialPortModem.ReadLine();

if (modemAnswer.Equals(expectedAnswer))
{
return true;
}
return false;

}

Is there a better method than ReadLine() for this job ?. The problem with ReadLine is that it reads until it finds a new-line char and some modems have the echo activated, so the reading returns the same issued command.
In some other programming languages there are methods that allows the system to wait until the expected answer is received or until a timeout timer expires.

What is the rigth way to do this in C# 2005 ?

Regards,

Carlos





Similar Threads
Thread Thread Starter Forum Replies Last Post
modem poja Visual Studio 2005 10 September 15th, 2011 03:31 AM
modem driver angelboy Linux 1 October 5th, 2007 03:27 PM
Modem poja Pro Visual Basic 2005 0 November 15th, 2006 11:34 PM
read/send email using WEBDEV and vb.net prashanthudupa.k Excel VBA 0 September 21st, 2006 06:39 AM
Phone and Modem options abelmirma Access VBA 0 March 3rd, 2005 12:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.