ERC
Posts: 1
Joined: Fri Jun 05, 2009 3:08 pm
Location: Indonesia

port_OnRead

Fri Jun 05, 2009 3:24 pm

Hi, i'm developing an application to send USSD command.

I'm trying to send this AT command :
AT+CUSD=1,"*888#",15

But on Event port_OnRead i get the result :
A

and on Event port_OnWritten i get result :
22

Please look at my code :

Code: Select all

     port = new SerialNET.Port();

     port.OnRead += new SerialNET.OnRead(port_OnRead);
     port.OnWritten += new SerialNET.OnWritten(port_OnWritten);
            
     port.Parent = this;
     Closing += new CancelEventHandler(FrmTransferList_FormClosing);

private void port_OnWritten(int bytes_written)
        {
            //txtWritten.Text = bytes_written.ToString();
            Debug.WriteLine("Write --> " + bytes_written.ToString());
        }

 private void port_OnRead(string Data)
        {
            // Note!
            // To convert from string to byte[] use SerialNET.Port.StringToByteArray()

            if (Data == null)
            {
                // Timeout
                //txtRead.Text = "Timeout";
                Debug.WriteLine("Timeout");
            }
            else
            {
                //txtRead.Text = Data;
                Debug.WriteLine("Hasil --> " + Data);
                port.Enabled = false;
            }
        }

port.Timeout = 10000;
                port.BaudRate = Convert.ToInt32(objSubdealer.BaudRate);
                port.ComPort = Convert.ToInt32(objSubdealer.Port.Replace("COM",""));
                port.Parity = SerialNET.Parity.No;
                port.StopBits = SerialNET.StopBits.One;
                port.Enabled = true;

                //Debug.WriteLine("AT+CUSD=1," + strUSSD + ",15");
                port.Write("AT+CUSD=1,\"*888#\",15" + "\r\n");


If i use HyperTerminal, the result is not like i mentioned above.

Is something i missed out ?

Return to “SerialTools”