On Thu, Feb 12, 2009 at 2:45 PM, Ramon Lopes <[email protected]> wrote:
> Hello everybody,
>
> I have been working with C#, specifically PortSerial, so I've already read a
> lot about that in MSDN Forum.
>
> In a nutshell, I have a client that will dial a number and make a request,
> whereas the server will response. The client dials, requests and everything
> works pretty fine, whereas the server answer the call, but the issue is just
> that doesn't receive the request! I am sure about that because the
> instruction "MessageBox.Show("Received: " + received);", received = "req",
> is never called, I mean the Message.ShowBox never shows "Received: req";
>
> Remark: I've been testing both application using two computers and phone
> lines, so that a computer is the server whereas the other one is the client.
>
> I've already spent much time working on it and until now I wasn't
> successful.
> Thanks in advance.
>
<snip>

> ###Server###
> this.serial = new SerialPort();
> this.serial.DtrEnable = true;
> this.serial.DataReceived += new
> SerialDataReceivedEventHandler(this.port_DataReceived);
>
> private void server_DataReceived(object sender, SerialDataReceivedEventArgs
> e)
> {
>             string received = serial.ReadExisting();
>             MessageBox.Show("Received: " + received);
>             switch (received) {
>                 case "\r\nRING\r\n":
>                     MessageBox.Show("Received: " + received);
>                     this.serial.WriteLine("ATA\r\n");
>                     Thread.Sleep(5000);
>                     MessageBox.Show("Answered");
>                     break;
>
>                 case "\r\nreq\r\n":
>                     MessageBox.Show("Request Received");
>                     this.serial.WriteLine("Oi\r\n");
>                     Thread.Sleep(5000);
>                     MessageBox.Show("Oi sent");
>                     break;
>             }
> }
> ###Server###
>
> --
> Ramon Pereira Lopes

Put a default in your switch statement and just do:
MessageBox.Show(received);  To see if you are getting anything.  Your
two case's may not be matching.

Reply via email to