Example #1
0
        private void DatoRecibido(object sender, SerialDataReceivedEventArgs e)
        {
            string Data_in = SpPuertos.ReadExisting();

            MessageBox.Show(Data_in);
            TxtRecibidos.Text = Data_in;
        }
Example #2
0
        private void DatoRecibido(object sender, SerialDataReceivedEventArgs e)
        {
            AccesoInterrupcion(SpPuertos.ReadExisting());

            /*string Data_in = SpPuertos.ReadExisting();
             * MessageBox.Show(Data_in);
             * TxtDatosRecibidos.Text = Data_in;*/
        }
Example #3
0
        private void DatoRecibido(object sender, SerialDataReceivedEventArgs e)
        {
            //----Se recibe el mensaje a través de DELEGADOS ???--------------
            AccesoInterrupcion(SpPuertos.ReadExisting());

            /*string Data_in = SpPuertos.ReadExisting();
             * MessageBox.Show(Data_in);
             * TxtDatosRecibidos.Text = Data_in;*/
        }
Example #4
0
        private void Datorecibido(object sender, SerialDataReceivedEventArgs e)
        {
            /*string Data_in = SpPuertos.ReadExisting();
             *
             * MessageBox.Show(Data_in);
             *
             * //string Data2_in = Data_in;
             *
             * //DatosRecibidos.Items.Add(Data2_in);*/

            AccesoInterrupcion(SpPuertos.ReadExisting());
        }
Example #5
0
 private void SpPuertos_DataReceived(object sender, SerialDataReceivedEventArgs eventArgs)
 {
     if (SpPuertos.IsOpen)
     {
         //  SerialPort sp = (SerialPort)sender;
         AccesoInterrupcion(SpPuertos.ReadExisting());
     }
     else
     {
         MessageBox.Show("Error, el puerto COM no esta abierto");
     }
 }
Example #6
0
 private void BtnEnviarDatos_Click(object sender, EventArgs e)
 {
     try
     {
         SpPuertos.DiscardOutBuffer();
         strBufferOut = TxtDatos_a_Enviar.Text;
         SpPuertos.Write(strBufferOut);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message.ToString());
     }
 }
Example #7
0
 private void EnviarDatos(string msg)
 {
     //Se llena el buffer de salida y se envían los datos
     try
     {
         //---------AQUÍ SE MANEJA EL MENSAJE ENVIADO-------------
         SpPuertos.DiscardOutBuffer();
         strBufferOut = msg;
         SpPuertos.Write(msg);
         //-------------------------------------------------------
     }
     catch (Exception ex)
     {
         //Si hay algún problema enviando datos se muestra por pantalla el error
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #8
0
 private void BtnEnviarDatos_Click(object sender, EventArgs e)
 {
     //Se llena el buffer de salida y se envían los datos
     try
     {
         //---------AQUÍ SE MANEJA EL MENSAJE ENVIADO-------------
         SpPuertos.DiscardOutBuffer();
         strBufferOut = TxtDatosEnviados.Text;
         SpPuertos.Write(strBufferOut);
         //-------------------------------------------------------
     }
     catch (Exception ex)
     {
         //Si hay algún problema enviando datos se muestra por pantalla el error
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #9
0
        private void BtnEnviarDatos_Click(object sender, EventArgs e)
        {
            try
            {
                SpPuertos.DiscardOutBuffer();
                //byte[] buffer_out = new byte[30];
                var pruebas = strinToByte(TxtEnviar.Text);
                //var prueba2 = Convert.ToDecimal(TxtEnviar.Text);
                // byte[] arreglo = { 0x1D, 0x49 , 0x40};
                // byte[] arreglo2 = { 0x1F, 0x74 };
                byte[] arreglo2 = { 0x1B, 0x6D };
                //buffer_out[1] = 0xbb;
                // int offset = 0;
                if (SpPuertos.IsOpen == true)
                {
                    //MessageBox.Show("Esta Abierto");
                    SpPuertos.WriteLine("");
                    SpPuertos.WriteLine("");
                    SpPuertos.WriteLine("meper d0nas¿ si te e fayado t pido perdon d la única forma q c dandote mi corason para kuando decidas volver, yo solo quiero tu amistad");
                    //SpPuertos.WriteLine("compañeros de oficina porfavor :) de antemano gracias");
                    SpPuertos.WriteLine("");
                    SpPuertos.WriteLine("");
                    SpPuertos.WriteLine("");
                    SpPuertos.WriteLine("");
                    SpPuertos.WriteLine("");
                    SpPuertos.WriteLine("");
                    SpPuertos.Write(arreglo2, 0, arreglo2.Length);
                    // SpPuertos.Read(arreglo, offset, arreglo.Length);
                }
                else
                {
                    MessageBox.Show("Esta Cerrado");
                }


                SpPuertos.Close();
                MessageBox.Show("Funciono?");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Example #10
0
        private void BotAbrirPuerto_Click(object sender, EventArgs e)     // Al hacer click sobre el boton de abrir puerto
        {
            try                                                           // en el caso de no haber error
            {
                if (BotAbrirPuerto.Text == "ABRIR")                       // se el puerto estaba cerrado
                {
                    SpPuertos.BaudRate = Int32.Parse(comboBaudRate.Text); // toma el BaudRate definido

                    SpPuertos.DataBits = 8;                               // fija los bits del dato en 8

                    SpPuertos.Parity = Parity.None;                       // define datos sin paridad

                    SpPuertos.StopBits = StopBits.One;                    // define un bit de parada

                    SpPuertos.Handshake = Handshake.None;

                    SpPuertos.PortName = ComboPuertos.Text; // guarda el nombre del puerto

                    try
                    {
                        SpPuertos.Open();               // abre el puerto

                        BotAbrirPuerto.Text = "CERRAR"; // modifica el texto del boton a "cerrar"
                    }
                    catch (Exception exc)               // al producirse un error dispone el mensaje pertinente
                    {
                        MessageBox.Show(exc.Message.ToString());
                    }
                }

                else if (BotAbrirPuerto.Text == "CERRAR") // si el puerto estaba abierto, se cierra el puerto y cambia el texto del boton
                {
                    SpPuertos.Close();

                    BotAbrirPuerto.Text = "ABRIR";
                }
            }
            catch (Exception exc) // se dispone un mensaje ante cualquier error
            {
                MessageBox.Show(exc.Message.ToString());
            }
        }
Example #11
0
 private void FormROV_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (SpPuertos.IsOpen)
     {
         DialogResult dialogo = MessageBox.Show("¿Desea salir de Settings ROV?\nSi cierra la ventana se cerraran todos los puertos.", "Puertos Abiertos",
                                                MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
         if (dialogo == DialogResult.OK)
         {
         }
         else
         {
             SpPuertos.Close();
             btnConectar.Text = "Conectar";
             e.Cancel         = true;
         }
     }
     else
     {
         SpPuertos.Close();
     }
 }
Example #12
0
        private void BtnConectar_Click(object sender, EventArgs e)
        {
            try
            {
                //'CONECTAR' configura el puerto, lo abre, cambia a 'DESCONECTAR' y habilita el botón 'Enviar Datos'
                if (BtnConectar.Text == "CONECTAR")
                {
                    SpPuertos.BaudRate  = Int32.Parse(CboBaudRate.Text);
                    SpPuertos.DataBits  = 8;
                    SpPuertos.Parity    = Parity.None;
                    SpPuertos.StopBits  = StopBits.One;
                    SpPuertos.Handshake = Handshake.None;
                    SpPuertos.PortName  = CboPuertos.Text;

                    try
                    {
                        SpPuertos.Open();
                        BtnConectar.Text       = "DESCONECTAR";
                        BtnEnviarDatos.Enabled = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                }
                //'DESCONECTAR' cierra el puerto, cambia a 'CONECTAR' y desabilita el botón 'Enviar Datos'
                else if (BtnConectar.Text == "DESCONECTAR")
                {
                    SpPuertos.Close();
                    BtnConectar.Text       = "CONECTAR";
                    BtnEnviarDatos.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                //Si hay algún problema conectándose se muestra por pantalla el error
                MessageBox.Show(ex.Message.ToString());
            }
        }
Example #13
0
 private void btnConectar_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnConectar.Text == "Conectar")
         {
             SpPuertos.BaudRate  = Convert.ToInt32(cbxBaudrate.Text);
             SpPuertos.DataBits  = 8;
             SpPuertos.Parity    = Parity.None;
             SpPuertos.StopBits  = StopBits.One;
             SpPuertos.Handshake = Handshake.None;
             SpPuertos.PortName  = cbxPorts.Text.ToString();
             try
             {
                 SpPuertos.Open();
                 tsStatusCOM.Visible = true;
                 tsStatusCOM.Text    = " '" + cbxPorts.SelectedItem.ToString() + "' Seleccionado.";
                 btnConectar.Text    = "Desconectar";
             }
             catch (Exception exc)
             {
                 MessageBox.Show(exc.Message.ToString());;
             }
         }
         else if (btnConectar.Text == "Desconectar")
         {
             SpPuertos.Close();
             listBox1.Items.Clear();
             tsStatusCOM.Visible = false;
             btnConectar.Text    = "Conectar";
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message.ToString());
     }
 }
Example #14
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (BtnConectar.Text == "CONECTAR")
                {
                    SpPuertos.BaudRate  = Int32.Parse(CboBaudRate.Text);
                    SpPuertos.DataBits  = 8;
                    SpPuertos.Parity    = Parity.None;
                    SpPuertos.StopBits  = StopBits.One;
                    SpPuertos.Handshake = Handshake.None;
                    SpPuertos.PortName  = CboPuertos.Text;

                    try
                    {
                        SpPuertos.Open();
                        BtnConectar.Text       = "DESCONECTAR";
                        BtnEnviarDatos.Enabled = true;
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show(exc.Message.ToString());
                    }
                }
                else if (BtnConectar.Text == "DESCONECTAR")
                {
                    SpPuertos.Close();
                    BtnConectar.Text       = "CONECTAR";
                    BtnEnviarDatos.Enabled = false;
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message.ToString());
            }
        }
Example #15
0
        private void BtnConectar_Click(object sender, EventArgs e)
        {
            try
            {
                if (BtnConectar.Text == "Conectar")
                {
                    SpPuertos.BaudRate  = 115200;
                    SpPuertos.DataBits  = 8;
                    SpPuertos.Parity    = Parity.None;
                    SpPuertos.StopBits  = StopBits.One;
                    SpPuertos.Handshake = Handshake.None;
                    SpPuertos.PortName  = CboPuertos.Text;

                    try
                    {
                        SpPuertos.Open();
                        BtnConectar.Text       = "Desconectar";
                        BtnEnviarDatos.Enabled = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message.ToString());
                    }
                }
                else if (BtnConectar.Text == "Desconectar")
                {
                    SpPuertos.Close();
                    BtnConectar.Text       = "Desconectar";
                    BtnEnviarDatos.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }