I update for this question and know it worked correctly..
I try to check balance in my mavecom modem but I got no response in my textbox. It stays empty.
Here my code :
private SerialPort _port;
private void simpleButton1_Click(object sender, EventArgs e)
{
_port = new SerialPort();
_port.PortName = cbPort.Text;
_port.BaudRate = 115200;
_port.Parity = Parity.None;
_port.DataBits = 8;
_port.StopBits = StopBits.One;
_port.Handshake = Handshake.RequestToSend;
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
port.Open();
port.Write("AT+CUSD=1,\"" + txtUSSD.Text + "\",15" + "\r");
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
try
{
// read the response.
var response = ((SerialPort)sender).ReadLine();
// Need to update the txtProvider on the UI thread .
//showing result in txtOutput based on txtProvider USSD Command
this.Invoke(new Action(() => txtOutput.Text = response));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
This is solved and can be use to check the balance....