Estoy haciendo una mini aplicacion en C# para hacer una consola de comandos AT para enviar a mi telefono por el puerto com, pero solo e logrado conectarme al equipo. pero este no atiene los comandos que le envio, alguien ya ah hecho esto?
public partial class Form1 : Form
{
private SerialPort port = new SerialPort("COM7", 96000, Parity.None, 8, StopBits.One);
public Form1()
{
InitializeComponent();
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
this.Invoke(new EventHandler(DoUpdate));
}
private void DoUpdate(object s, EventArgs e)
{
txtLog.AppendText("----------------\n");
txtLog.AppendText(port.ReadExisting());
}
private void btnConectar_Click(object sender, EventArgs e)
{
if (port.IsOpen == false)
{
try
{
port.Open();
txtLog.AppendText("Conectado COM7\n");
}
catch (Exception oex)
{
MessageBox.Show(oex.ToString());
}
}
}
private void btnDesconectar_Click(object sender, EventArgs e)
{
if (port.IsOpen)
{
port.Close();
txtLog.AppendText("Cerrada la conexion...\n");
}
}
private void btnEnviar_Click(object sender, EventArgs e)
{
try
{
port.WriteLine(txtCmd.Text);
}
catch (Exception wex)
{
MessageBox.Show(wex.ToString());
}
}
}
public partial class Form1 : Form
{
private SerialPort port = new SerialPort("COM7", 96000, Parity.None, 8, StopBits.One);
public Form1()
{
InitializeComponent();
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
this.Invoke(new EventHandler(DoUpdate));
}
private void DoUpdate(object s, EventArgs e)
{
txtLog.AppendText("----------------\n");
txtLog.AppendText(port.ReadExisting());
}
private void btnConectar_Click(object sender, EventArgs e)
{
if (port.IsOpen == false)
{
try
{
port.Open();
txtLog.AppendText("Conectado COM7\n");
}
catch (Exception oex)
{
MessageBox.Show(oex.ToString());
}
}
}
private void btnDesconectar_Click(object sender, EventArgs e)
{
if (port.IsOpen)
{
port.Close();
txtLog.AppendText("Cerrada la conexion...\n");
}
}
private void btnEnviar_Click(object sender, EventArgs e)
{
try
{
port.WriteLine(txtCmd.Text);
}
catch (Exception wex)
{
MessageBox.Show(wex.ToString());
}
}
}