Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: BackgroundWorker Pin
Luc Pattyn12-Feb-10 12:47
sitebuilderLuc Pattyn12-Feb-10 12:47 
QuestionDocumentation description about the method and its parameters. Pin
Blubbo12-Feb-10 3:29
Blubbo12-Feb-10 3:29 
AnswerRe: Documentation description about the method and its parameters. Pin
R. Giskard Reventlov12-Feb-10 3:33
R. Giskard Reventlov12-Feb-10 3:33 
AnswerRe: Documentation description about the method and its parameters. Pin
dan!sh 12-Feb-10 3:36
professional dan!sh 12-Feb-10 3:36 
GeneralRe: Documentation description about the method and its parameters. Pin
Blubbo12-Feb-10 3:46
Blubbo12-Feb-10 3:46 
QuestionMultiPage-Application - Navigation Pin
PingOfDeath198312-Feb-10 3:09
PingOfDeath198312-Feb-10 3:09 
AnswerRe: MultiPage-Application - Navigation Pin
dan!sh 12-Feb-10 3:11
professional dan!sh 12-Feb-10 3:11 
QuestionAT command problem Pin
saeidfarahi12-Feb-10 2:44
saeidfarahi12-Feb-10 2:44 
Hi, I wrote some code for two modems: one, must send some string and another must answer the call and receive the string. My receiver modem is a D-Link voice-modem which has COM port, and the sender modem is a NetForce usb2.0 data-modem. Two modems are connected to two different computers and each one has a phone line. I first run the receiver's code and then the sender's code. Here's the code for each of them and log files:

The receiver modem's code:

SerialPort sp = new SerialPort("COM1");

private void Form1_Load(object sender, EventArgs e)
{
    sp.NewLine = "\r\n";
    sp.Parity = Parity.None;
    sp.DataBits = 8;
    sp.StopBits = StopBits.One;
    sp.DtrEnable = true;
    sp.WriteBufferSize = 1024;

    sp.Open();
    sp.WriteLine("ATE0");
    sp.BaseStream.Flush();
    sp.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(sp_DataReceived);
}

void sp_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
    string str;
    str = sp.ReadLine();
    if (str == "RING")
    {
        sp.WriteLine("ATA");
        sp.BaseStream.Flush();
    }
    System.IO.File.AppendAllText("c:\\log_receiver.txt", str + "\r\n");
}

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
    sp.Close();
}


and its log file(log_receiver.txt):

OK

RING

CONNECT 9600

And sender's code:

SerialPort sp = new SerialPort("COM8");

private void Form1_Load(object sender, EventArgs e)
{
    sp.NewLine = "\r\n";
    sp.Parity = Parity.None;
    sp.DataBits = 8;
    sp.StopBits = StopBits.One;
    sp.DtrEnable = true;
    sp.WriteBufferSize = 1024;

    sp.Open();
    sp.WriteLine("ATE0");
    sp.WriteLine("ATDT6632");
    sp.BaseStream.Flush();
    sp.WriteLine("My string to be sent");
    sp.BaseStream.Flush();
    sp.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(sp_DataReceived);
}

void sp_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
    string str;
    str = sp.ReadLine();
    File.AppendAllText("C:\\log_sender.txt", str + "\r\n");
}

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
    sp.Close();
}


and the sender's log file(log_sender.txt);
ATE0
OK

NO CARRIER

I have read all the commands of the Hayes AT commands, but there were no tutorial about how to use the commands(I know that using commands may differ in some modems). I wanted to know that where's the problem of my code and does anyone have an idea about using AT commands in order to send and receive data between modems?
AnswerRe: AT command problem Pin
Richard MacCutchan12-Feb-10 3:24
mveRichard MacCutchan12-Feb-10 3:24 
GeneralRe: AT command problem Pin
saeidfarahi12-Feb-10 3:28
saeidfarahi12-Feb-10 3:28 
GeneralRe: AT command problem Pin
Richard MacCutchan12-Feb-10 3:49
mveRichard MacCutchan12-Feb-10 3:49 
QuestionThread sychronization Pin
koleraba12-Feb-10 2:35
koleraba12-Feb-10 2:35 
AnswerRe: Hi Pin
Not Active12-Feb-10 4:07
mentorNot Active12-Feb-10 4:07 
GeneralRe: Hi Pin
koleraba12-Feb-10 5:31
koleraba12-Feb-10 5:31 
QuestionAppDomain Pin
Le centriste12-Feb-10 2:10
Le centriste12-Feb-10 2:10 
AnswerRe: AppDomain Pin
dan!sh 12-Feb-10 3:25
professional dan!sh 12-Feb-10 3:25 
GeneralRe: AppDomain Pin
Le centriste12-Feb-10 3:32
Le centriste12-Feb-10 3:32 
AnswerRe: AppDomain Pin
kevinnicol12-Feb-10 5:26
kevinnicol12-Feb-10 5:26 
QuestionTree view drawing problem Pin
gwithey11-Feb-10 23:32
gwithey11-Feb-10 23:32 
QuestionText Files Pin
muka6611-Feb-10 23:30
muka6611-Feb-10 23:30 
JokeRe: Text Files Pin
Richard MacCutchan11-Feb-10 23:31
mveRichard MacCutchan11-Feb-10 23:31 
GeneralRe: Text Files Pin
muka6611-Feb-10 23:33
muka6611-Feb-10 23:33 
GeneralRe: Text Files Pin
Richard MacCutchan12-Feb-10 0:11
mveRichard MacCutchan12-Feb-10 0:11 
AnswerRe: Text Files Pin
Anurag Gandhi11-Feb-10 23:49
professionalAnurag Gandhi11-Feb-10 23:49 
AnswerRe: Text Files Pin
OriginalGriff11-Feb-10 23:50
mveOriginalGriff11-Feb-10 23:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.