/ Published in: C#
Configure program for CalAmp lmu-800 and skypatrol nitro gps avl , (works with every device who support AT Command)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/**************************************************************** * CONFIGURADOR DISPOSITIVOS AVT * ------------------------------ * * -MODELOS SOPORTADOS: CALAMP LMU-800 - SKYPATROL NITRO * (Cualquier dispositivo que ocupe comandos AT) * -CONFIGURA SEGUN APN,SERVIDOR Y MODELO * -ENTREGA DIAGNOSTICO DE DISPOSITIVO Y DATOS GPS EN TIEMPO REAL * * TO DO: * ------- * - !!!!CAMBIAR TEXTBOX MULTILINEA POR RICHTEXTBOX NAOO¡¡¡¡ * -ENVIAR COMANDOS UNICOS * -MANEJO DE ERRORES EN SU TOTALIDAD (EVITAR CRASHING DE APLICACION) * -CAPACIDAD DE LEER SCRIPT DE ARCHIVOS TXT * -MODIFICAR APN (AGREGAR, QUITAR, MODIFICAR) * -CAPACIDAD GUARDAR CONFIGURACION * -EXTRAER INFORMACION DE FORMA LEGIBLE * -FUNCIONALIDADES SEGUN REQUERIMIENTOS * * .-YEEEEEE-. * ***************************************************************/ using System; using System.Threading; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.IO.Ports; using System.Windows.Forms; using System.Timers; namespace miauuu { public partial class MainForm : Form { /*INTERVALO COMANDOS AT *Un valor minimo de 600 ms puede producir problemas de comunicacion *al enviar comandos AT produciendose que los comandos *no lleguen completos al destino. *valor int intervalo = 600 */ int intervalo = 600; public MainForm() { InitializeComponent(); //OBTENCION LISTA PUEROS COM string[] ArrayComPortsNames = null; int index = -1; string ComPortName = null; ArrayComPortsNames = SerialPort.GetPortNames(); do { index += 1; cboPorts.Items.Add(ArrayComPortsNames[index]); } while (!((ArrayComPortsNames[index] == ComPortName) || (index == ArrayComPortsNames.GetUpperBound(0)))); Array.Sort(ArrayComPortsNames); //OBTENER PRIMER COM EN COMBOBOX if (index == ArrayComPortsNames.GetUpperBound(0)) { ComPortName = ArrayComPortsNames[0]; } cboPorts.Text = ArrayComPortsNames[0]; btnPortState.Enabled = true; //LISTA APN cboApn.Items.Add("imovil.entelpcs.cl"); cboApn.Items.Add("od1.korem2m.com;guest;1234"); cboApn.Items.Add("data.m2mcloudconnect.com"); cboApn.Text = cboApn.Items[0].ToString(); //MODELOS DE GPS SOPORTADOS cboModel.Items.Add("Calamp LMU-800"); cboModel.Items.Add("Skypatrol Nitro"); cboModel.Text = cboModel.Items[0].ToString(); //SERVIDORES GPS cboserver.Items.Add("StartrackLLC"); cboserver.Items.Add("Gipisi"); cboserver.Text = cboserver.Items[0].ToString(); //verificador de Timer en 3 (neutro) txtverifier.AppendText("3"); } //BOTON CONECTAR PUERTO COM private void BtnPortStateClick(object sender, EventArgs e) { if (btnPortState.Text == "Conectar") { btnPortState.Text = "Desconectar"; //configuracion permanente puerto COM y apertura ComPort.PortName = Convert.ToString(cboPorts.Text); ComPort.BaudRate = 115200; ComPort.DataBits = 8; ComPort.StopBits = StopBits.One; ComPort.Handshake = Handshake.None; ComPort.Parity = Parity.None; ComPort.Open(); //habilitar controles de operacion y configuracion cboPorts.Enabled = false; btnatig.Enabled = true; btnatic.Enabled = true; button1.Enabled = true; cboModel.Enabled = true; cboApn.Enabled = true; cboserver.Enabled = true; chkupdate.Enabled = true; } else if (btnPortState.Text == "Desconectar") { btnPortState.Text = "Conectar"; //apagar TIMER, cerrar puerto COM y deshabilitar controles de oper y conf timer1.Stop(); ComPort.Close(); cboPorts.Enabled = true; btnatig.Enabled = false; btnatic.Enabled = false; button1.Enabled= false; cboModel.Enabled = false; cboApn.Enabled = false; cboserver.Enabled = false; chkupdate.Enabled = false; } } /*BOTON CONFIGURACION DE DISPOSITIVO *aca va el script integrado en el codigo del programa *se lee segun opciones elegidas. *TIMER se apaga al configurar y se activa automaticamente *al terminar configuracion CALAMP y se llena ProgressBar para indicar progreso **/ private void Button1Click(object sender, EventArgs e) { progressBar1.Value = 0; button1.Text = "Configurando"; //CONFIGURACION CALAMP STARTRACK - GIPISI if(cboModel.Text == "Calamp LMU-800") { //Configuracion STARTRACK if(cboserver.Text == "StartrackLLC") { ComPort.WriteLine("ATS145=2\r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("ATS127=73\r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("ATS142=10\r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("ATS144=10 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("ATS156=1 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("ATS174=4\r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("at$app param 2319,0,206.71.179.75 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("at$app param 769,0,20509 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); //LINEA QUE INDICA APN EN SCRIPT STARTRACK ComPort.WriteLine("AT$APP PARAM 2306,0," + cboApn.Text + "\r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 2314,0,web \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 2315,0,web \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("at$app param 2320,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("at$app param 2311,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 1035,0,139 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 257,0,2778 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 258,0,10 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 262,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 263,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 264,0,45 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 265,0,180 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 265,1,43200 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 265,14,43200 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 265,15,10 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,0,15,0,0,0,1,3,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,1,16,0,0,0,1,2,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,2,15,0,0,0,30,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,3,15,0,0,0,13,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,4,16,0,0,0,30,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,5,16,0,0,0,13,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,6,18,0,0,0,13,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,7,18,1,0,0,13,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,8,3,0,0,0,7,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,9,3,0,0,0,13,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,10,17,0,0,0,1,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,11,18,0,0,0,1,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,12,18,1,0,0,1,13,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,13,7,0,0,0,1,7,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,14,42,0,2,0,1,26,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,15,3,0,0,0,13,3,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); progressBar1.PerformStep(); ComPort.WriteLine("AT$APP PARAM 512,16,18,3,0,0,38,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,17,18,3,0,0,13,4,0,0 \r"); progressBar1.PerformStep(); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,18,18,4,0,0,37,0,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,19,4,5,0,0,1,10,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,20,5,5,0,0,1,12,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,21,4,1,0,0,1,11,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,22,4,2,0,0,1,8,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,23,5,2,0,0,1,9,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,24,5,3,0,0,1,41,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,25,4,3,0,0,1,40,0,0 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2313,0,60 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 771,0,20 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 771,1,40 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 771,2,60 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 771,3,90 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 771,4,120 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 771,5,150 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 270,0,5 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 271,0,3 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 272,0,3 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 270,5,5 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 271,5,3 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 272,5,3 \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("atreset \r"); Thread.Sleep(intervalo); progressBar1.PerformStep(); outputbox.AppendText(ComPort.ReadExisting() + "\n"); outputbox.AppendText("\n"); outputbox.AppendText("\n"); outputbox.AppendText("\n---yeyeyeyeee---"); received.Clear(); //SE ACTUALIZA INFORMACION ATIC AUTOMATICAMENTE Y SE ENCIENDE TIMER txtverifier.Text = "0"; ComPort.WriteLine("atic\r"); Thread.Sleep(intervalo); received.AppendText(ComPort.ReadExisting() + ""); Thread.Sleep(intervalo); } else if (cboserver.Text == "Gipisi") { //Configuracion GIPISI ComPort.WriteLine("AT$APP PARAM 2319,0,rastreo.gipisi.com \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 769,0,10500 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 774,0,10500 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2313,0,300 \r"); Thread.Sleep(intervalo); /*Debido a mayor numero de lineas al configurar APN en GIPISI *se opta por SWITCH CASE uno por cada APN a utiliza*/ switch (cboApn.SelectedIndex) { case 0: //ENTEL outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2306,0,\"imovil.entelpcs.cl\" \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2314,0,\"\" \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2315,0,\"\" \r"); Thread.Sleep(intervalo); break; case 1: //KORE AUS outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2306,0,\"od1.korem2m.com\" \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2314,0,\"guest\" \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2315,0," + "\"1234\"" + " \r"); Thread.Sleep(intervalo); break; case 2: //VODAFONE outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2306,0,\"data.m2mcloudconnect.com\" \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2314,0,\"\" \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 2315,0,\"\" \r"); Thread.Sleep(intervalo); break; } outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("ATS145=2 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 1035,0,139 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 262,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 263,0,1000 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 264,0,40 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,0,60 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,1,1200 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,2,300 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,3,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,4,10 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,5,60 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,14,43200 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 265,15,10 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("ATS160=50 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("ATS161=17 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 257,0,2777 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 258,0,2 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 259,0,5 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 260,0,5 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 1029,0,255,7 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,0,15,0,0,0,1,3,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,1,16,0,0,0,1,2,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,2,43,0,0,0,13,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,3,42,0,0,0,30,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,4,42,0,0,0,31,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,5,18,16,0,0,1,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,6,18,16,0,0,30,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,7,18,16,0,0,32,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,8,14,0,0,0,13,5,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,9,18,5,0,0,13,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,10,18,5,0,0,31,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,11,18,5,0,0,1,32,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,12,18,5,0,0,30,5,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,13,13,0,16,1,1,33,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,14,13,0,0,0,30,5,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,15,13,0,16,1,30,1,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,16,18,1,16,1,70,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,17,4,3,0,0,1,10,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,18,5,3,0,0,1,12,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,19,4,4,0,0,1,46,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,20,5,1,0,0,1,11,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,21,42,0,2,0,13,4,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,22,18,4,3,0,1,26,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,23,43,0,2,0,30,4,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,24,3,0,0,0,7,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,25,17,0,0,0,1,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,26,41,100,1,0,1,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,27,70,1,0,0,1,57,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,28,7,1,0,0,1,7,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,29,16,0,0,0,13,2,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,30,15,0,0,0,30,2,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,31,18,2,2,0,22,3,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,95,3,0,0,0,13,14,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,96,18,14,0,0,38,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,97,18,14,0,0,13,15,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP PARAM 512,98,18,15,0,0,37,0,0,0 \r"); Thread.Sleep(intervalo); outputbox.AppendText(ComPort.ReadExisting() + "\n"); ComPort.WriteLine("AT$APP REBOOT \r"); Thread.Sleep(1200); outputbox.AppendText(ComPort.ReadExisting() + "\n"); outputbox.AppendText("\n"); outputbox.AppendText("\n"); outputbox.AppendText("\n---yeyeyeyeee---"); received.Clear(); //SE ACTUALIZA INFORMACION ATIC AUTOMATICAMENTE Y SE ENCIENDE TIMER txtverifier.Text = "0"; ComPort.WriteLine("atic\r"); Thread.Sleep(intervalo); received.AppendText(ComPort.ReadExisting() + ""); Thread.Sleep(intervalo); } } else if (cboModel.Text == "Skypatrol Nitro") //FALTA AGREGAR SCRIPT SKYPATROL NITRO (seleccion sirve para probar cosas) { outputbox.AppendText("Falta probar script skypatrol :(\n"); /*switch (cboApn.SelectedIndex) { case 0: outputbox.AppendText(cboApn.Text); break; case 1: outputbox.AppendText(cboApn.Text); break; }*/ } button1.Text = "Configurar"; } //BOTON ATIC PARA OBTENER INFORMACION DE DISPOSITIVO CALAMP LMU-800 void BtnaticClick(object sender, EventArgs e) { //Verificador de TIMER se establece en "0" (indicando ATIC activo al timer) txtverifier.Text = "0"; received.Clear(); ComPort.WriteLine("atic\r"); Thread.Sleep(intervalo); received.AppendText(ComPort.ReadExisting() + ""); } //BOTON ATIG PARA OBTENER DATOS DEL RECEPTOR GPS DISPOSITIVO CALAMP LMU-800 void BtnatigClick(object sender, EventArgs e) { //Verificador de TIMER se establece en "1" (indicando ATIG activo al timer) txtverifier.Text = "1"; received.Clear(); ComPort.WriteLine("atig\r"); Thread.Sleep(intervalo); received.AppendText(ComPort.ReadExisting() + ""); } //CONTROL TIMER PARA ACTUALIZACION EN TIEMPO REAL DATOS DISPOSITIVO GPS void Timer1Tick(object sender, EventArgs e) { /*TIMER verifica si txtverifier contiene "0" o "1" segun sea el caso *actualiza ATIG o ATIC cada 1600 milisegundos (definido x chkupdate) *TIMER se apaga al enviar configuracion y al desconectar puerto COM * 0 = atic * 1 = atig * 3 = timer sin operar*/ if (txtverifier.Text == "0") { received.Clear(); ComPort.WriteLine("atic\r"); Thread.Sleep(intervalo); received.AppendText(ComPort.ReadExisting() + ""); } else if (txtverifier.Text == "1") { received.Clear(); ComPort.WriteLine("atig\r"); Thread.Sleep(intervalo); received.AppendText(ComPort.ReadExisting() + ""); } } //CHECKBOX DE ACTUALIZACION EN TIEMPO REAL void ChkupdateCheckedChanged(object sender, EventArgs e) { /*Si CHKUPDATE esta marcado entonces enciende TIMER y actualiza datos * *segun marcador TXTVERIFIER cada 1600 milisegundos *Si CHKUPDATE esta desmarcado entonces apaga TIMER. * */ { timer1.Interval = 1600 ; timer1.Start(); } { timer1.Stop(); } } //LIMPIAR REGISTRO OUTPUTBOX (ventana configuracion) void Button2Click(object sender, EventArgs e) { outputbox.Clear(); progressBar1.Value = 0; } //CIERRA LA APLICACION COMO SE DEBE (detiene TIMER, cierra puerto COM) void BtnexitClick(object sender, System.EventArgs e) { timer1.Stop(); cboPorts.Enabled = false; btnatig.Enabled = false; btnatic.Enabled = false; button1.Enabled = false; cboModel.Enabled = false; cboApn.Enabled = false; cboserver.Enabled = false; chkupdate.Enabled = false; if(ComPort.IsOpen == true) { progressBar1.Value = 0; progressBar1.Maximum = 90; progressBar1.Step = 30; received.Clear(); received.AppendText("...CERRANDO PUERTO COM..."); Thread.Sleep(300); progressBar1.PerformStep(); received.AppendText("\n"); Thread.Sleep(300); progressBar1.PerformStep(); received.AppendText("\n"); Thread.Sleep(300);//500 progressBar1.PerformStep(); ComPort.Close(); received.AppendText("....SALIENDO...."); Thread.Sleep(300); } else { received.Clear(); received.AppendText("....SALIENDO...."); Thread.Sleep(300); } Close(); } } }