elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  software en lenguaje c
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] 2 Ir Abajo Respuesta Imprimir
Autor Tema: software en lenguaje c  (Leído 4,800 veces)
GAWAIN2010

Desconectado Desconectado

Mensajes: 5


Ver Perfil
software en lenguaje c
« en: 26 Abril 2015, 04:28 am »

Hola a todos:

Un compañero me envio el codigo fuente de un software hecho en C para revisarlo, verificar su funcionamiento y de ser necesario modificarlo. El caso es que al tratar de compilarlo por el PIC CCS (quen es el mismo utilizado por el creador del software), me salen una serie de errores y quien me envio el programa, me indica que a él no le aparece ningun tipo de error y le corre perfectamente. Debo aclarar que sé muy poco de lenguaje C y su forma de operar ya que me he especializado en Basic.

Por lo anterior les consulto que debo hacer para corregir esto.

Agradezco su ayuda.

Saludos,

GAWAIN

Mod: No escribir en mayúsculas mensajes ni títulos


« Última modificación: 26 Abril 2015, 04:34 am por engel lex » En línea

engel lex
Moderador Global
***
Desconectado Desconectado

Mensajes: 15.514



Ver Perfil
Re: software en lenguaje c
« Respuesta #1 en: 26 Abril 2015, 04:39 am »

con esa información podría ser desde un software mal instalado, hasta un código mal copiado....

muestra el codigo (si es muy largo usa pastebin) muestra los errores y tendríamos algo para empezar

antes de escribir algo, porfa lee estos 2 temas
10 pasos para plantear una duda informática
FAQ : Como hacer preguntas "inteligentes"


En línea

El problema con la sociedad actualmente radica en que todos creen que tienen el derecho de tener una opinión, y que esa opinión sea validada por todos, cuando lo correcto es que todos tengan derecho a una opinión, siempre y cuando esa opinión pueda ser ignorada, cuestionada, e incluso ser sujeta a burla, particularmente cuando no tiene sentido alguno.
GAWAIN2010

Desconectado Desconectado

Mensajes: 5


Ver Perfil
Re: software en lenguaje c
« Respuesta #2 en: 26 Abril 2015, 22:43 pm »

Buenas Tardes engel:

Gracias por tu respuesta. Como soy nuevo acá no sé lo que quieres decir con pastebin, sin embargo como el codigo no es muy largo, te lo anexo por aca.

Algunos de los errores que me dan son Error 51 que es la declaracion de todas las variables lo cual no veo logico por cuanto la sintaxis y logica estan bien.

El codigo es el siguiente (y mucho agradezco tu ayuda). El PIC asociado es el 18F2520 con un oscilador de 4 MHz.

Código
  1. //OMAR DAVILA - BLADIMIR VERGARA - JOSE DIAZ
  2. //CONFIGURACION DE PUERTO SERIAL
  3.  
  4. #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)//9600
  5.  
  6.  
  7. //DECLARACION DE VARIABLES  
  8.   int ret=500,ret_alrm=400;//200:1min
  9.  
  10. **********   int ret_env=8000;//RETARDO DE ENVIO 1000=1S
  11.  
  12.   int f1=0,f2=0,f3=0,f4=0,f5=0,f6=0;//BANDERAS DE ALARMAS
  13.   int16 uptime,retardo1,retardo2;//CONTADORES DE TIEMPO
  14.   int e,n,cap=0,fn,lf=0,lfe,in=0,ie=0,ip=0,inr=0,sms=0,posi=0,hist=0,seg=0,min=0,rep;//OTRAS VARIABLES
  15.   int alrm1=pin_C0,alrm2=pin_C1,alrm3=pin_C2,alrm4=pin_C3,alrm5=pin_C4,alrm6=pin_C5,s1=pin_A4,s2=pin_A5;//PINES DE ENTRADA
  16.   int ca1=0,ca2=0,ca3=0,ca4=0,ca5=0,ca6=0;//CONTADORES DE ALARMA
  17.   int pwr=pin_B0,led_senal=pin_B7,salida1=pin_A0,salida2=pin_A2,alarm_salida1=0,alarm_salida2=0,record=0,alrmH,alrmT;//PINES DE SALIDA
  18.   int const nros=12;//NRO MAXIMO DE CONTACTOS A LEER EN SIM
  19.   int const etqs=7;//NRO MAXIMO DE SMS DE ETIQUETAS A LEER EN SIM
  20.   char c,l;//VARIABLES PARA CARACTER DE ENTRADA Y CODIGO DE SMS ENTRANTE RESPECTIVAMENTE
  21.   char ctrlz=26;//combinacion de teclas "ctrl+z"
  22.   char pos[2];//POSICION DEL SMS ENTTRANTE
  23.   char intentos[2];//INTENTOS DE ENCENDIDO ANTES DE BLOQUEAR LUEGO DE NO DETECTAR PRESENCIA DE MODULO GSM
  24.   char NUM[nros][14];//MATRIX DE PARA ALMACENAR CONTACTOS
  25.   char ETQ[etqs][21]={"_s/nombre", "_a1", "_a2", "_a3", "_a4", "_a5", "_a6"};//MATRIX PARA LAS ETIQUETAS
  26.   char NREM[14];//PARA ALMACENAR TEMPORALMENTE EL NRO DE REMITENTE
  27.   void mensaje_etqX_listcontactos (unsigned int etiq,unsigned int cnd);
  28.   void fcn_int_rda (void);
  29.   void reset(unsigned int x);
  30.   void capturar (void);
  31.   void ext_nros (void);
  32.   void ext_etqs (void);
  33.   void inic_nrem (void);
  34.   void inic_nrem (void);
  35.   void enviar_reporte (unsigned int x);
  36.   void check_sal(void);
  37.   unsigned int ident_nrem (void);
  38.  
  39.   void leer_nvosms (unsigned int x);
  40.  
  41.   void mensaje_etqX_listcontactos (unsigned int etiq,unsigned int cnd);
  42.   void capturar (void);
  43.   void encender_modem (void);
  44.   void config_modem (void);
  45.  
  46.  
  47. //AUTO RESET  
  48. void reset(unsigned int x){
  49.   switch (x){
  50.   case 0:
  51.   reset_cpu();  
  52.   case 1:
  53.   write_eeprom(0x00,'1');reset_cpu();
  54.   }
  55.   }
  56.  
  57.  
  58.  
  59. //BUCLE DE ESPERA DE CAPTURA  
  60. void capturar(void)
  61. {
  62.  
  63. while(cap==0){}
  64.  
  65. delay_ms(ret_env);
  66.  
  67. }
  68.  
  69. //FUNCION DE BLOQUEO  
  70. void bloqueo(unsigned int x)
  71. {
  72. switch (x)
  73. {
  74. case 1:
  75.      while(true){output_high (led_senal);delay_ms(150);output_low (led_senal);delay_ms(2000);}
  76.  
  77. case 2:
  78.      while(true){output_high (led_senal);delay_ms(150);output_low (led_senal);delay_ms(150);output_high (led_senal);delay_ms(150);output_low (led_senal);delay_ms(2000);}
  79.  
  80. }
  81. }
  82.  
  83.  
  84. //FUNCION DE CAPTURA DINAMICA POR PUERTO SERIAL
  85. void fcn_int_rda(void)
  86. {
  87.  
  88.   c=0x00;
  89.   if (kbhit () )
  90.   {
  91.      c=getc ();
  92.  
  93.      switch (fn)
  94.      {
  95.         case 0: if (c=='+')
  96.            fn=5;
  97.  
  98.         break;
  99.  
  100.  
  101.         case 1: if (c==('K' || 'R'))
  102.         {
  103.            NUM[n-1][0]=NULL;
  104.            lfe=1;
  105.            fn=100;
  106.         }
  107.         if (c==',')
  108.            fn=2;
  109.  
  110.         break;
  111.  
  112.         case 2:
  113.         if (c!=',')NUM[n-1][in++]=c;
  114.         else
  115.         {
  116.            NUM[n-1][in++]=NULL;
  117.            in=0;
  118.            lfe=3;
  119.            fn=100;
  120.         }
  121.         break;
  122.         case 3:
  123.         if (c=='\n')
  124.            lf++;
  125.         if (lf==2)
  126.         {
  127.            lf=0;
  128.            fn=4;
  129.         }
  130.  
  131.         if (c==('K' || 'R'))
  132.         {
  133.            lf=0;
  134.            lfe=1;
  135.            fn=100;
  136.         }
  137.  
  138.         break;
  139.  
  140.         case 4:
  141.         if (c!='\r')ETQ[e-1][ie++]=c;
  142.         else
  143.         {
  144.            ETQ[e-1][ie++]=NULL;
  145.            ie=0;
  146.            lfe=3;
  147.            fn=100;
  148.         }
  149.         break;
  150.  
  151.         case 5:
  152.         if (c==',')fn=6;
  153.  
  154.         break;
  155.         case 6:
  156.         if (c!='\r')pos[ip++]=c;
  157.         else
  158.         {
  159.            pos[ip++]=NULL;
  160.            sms=1;
  161.            fn=99;
  162.         }
  163.         break;
  164.         case 7:
  165.         if (c==',')fn=12;
  166.  
  167.         if (c==('K' || 'R'))
  168.         {
  169.          lfe=1;
  170.          fn=100;
  171.         }
  172.  
  173.         /*
  174.          if (c=='R')
  175.          {
  176.          if(err<4)
  177.          {
  178.             err++;
  179.             lfe=1;
  180.             fn=101;
  181.          }
  182.          }
  183.          */
  184.         break;
  185.  
  186.         case 12: if (c=='2'||c=='4')
  187.            {
  188.            NREM[inr++]=0x22;
  189.            NREM[inr++]='0';
  190.            NREM[inr++]=c;
  191.            fn=8;
  192.            }
  193.         break;
  194.  
  195.         case 8: if (c!=',')
  196.            NREM[inr++]=c;
  197.         else
  198.         {
  199.            NREM[inr++]=NULL;
  200.            fn=9;
  201.         }
  202.         break;
  203.         case 9: if (c=='\n')
  204.            fn=10;
  205.  
  206.         break;
  207.  
  208.         case 10: if (c!='\r')
  209.         {
  210.            l=c;
  211.         }
  212.         else
  213.         {
  214.            lfe=3;
  215.            fn=100;
  216.         }
  217.         break;
  218.         case 11:
  219.         if (c=='+')
  220.         {
  221.            lfe=3;
  222.            fn=100;
  223.         }
  224.  
  225.         if (c=='R')
  226.         {
  227.            lfe=1;
  228.            fn=100;
  229.  
  230.         /*if(err<3)
  231.          {
  232.             err++;
  233.             lfe=1;
  234.             fn=101;
  235.          }
  236.          else{
  237.             err=0;
  238.             lfe=1;
  239.             fn=100;
  240.              }*/
  241.         }
  242.         break;
  243.  
  244.         case 20: if (c=='K')
  245.         {
  246.            lfe=1;
  247.            fn=100;
  248.         }
  249.  
  250.         break;
  251.         case 100: if (c=='\n')
  252.            lf++;
  253.         if (lf==lfe)
  254.         {
  255.            lf=0;
  256.            lfe=0;
  257.            fn=99;
  258.            cap=1;
  259.         }
  260.  
  261.         break;
  262.  
  263.         case 101: if (c=='\n')
  264.            lf++;
  265.         if (lf==lfe)
  266.         {
  267.            lf=0;
  268.            lfe=0;
  269.            fn=99;
  270.            cap=2;
  271.         }
  272.  
  273.         break;
  274.  
  275.         default: c=0x00;
  276.  
  277.         break;
  278.      }
  279.   }
  280. }
  281.  
  282. //INTERRUPCION DE CAPTURA DE CARACTERES POR RX DE PUERTO SERIAL
  283. #int_rda
  284. void serial_isr()
  285. {
  286.   fcn_int_rda () ;
  287. }
  288.  
  289. ///////////////////////////////////////////////////
  290.  
  291. //INTERRUPCION DE TIEMPO REAL
  292. #int_RTCC
  293. void RTCC_isr(void)
  294. {
  295.   retardo1++;
  296.   retardo2++;
  297.   uptime++;
  298.   if (uptime==120){uptime=0; seg++; }
  299.   if (seg==60){min++; seg=0; }
  300. }
  301.  
  302. //FUNCION PARA EXTRAER NROS DESDE LA SIM
  303. void ext_nros(void)
  304. {
  305.   int x=0;
  306.   n=0;
  307.   while (x==0&&n<nros)
  308.   {
  309.      fn=1;
  310.      n++;
  311.      printf ("AT+CPBR=%u\r\n",n);
  312.      //while (cap==0){}
  313.      //cap=0;
  314.      capturar();
  315.      if (NUM[0][0]== NULL)bloqueo(2);
  316.      if (NUM[n-1][0]== NULL)
  317.      {
  318.         n--;
  319.         x=1;
  320.      }
  321.      delay_ms (ret);
  322.   }
  323. }
  324.  
  325. //FUNCION PARA EXTRAER SMS DE ETIQUETAS DESDE LA SIM
  326. void ext_etqs(void)
  327. {
  328.   int x=0;
  329.   e=0;
  330.   while (x==0 && e<etqs)
  331.   {
  332.      fn=3;
  333.      e++;
  334.      printf ("AT+CMGR=%u\r\n",e);
  335.      capturar();
  336.      if (ETQ[e-1][0]=='_')
  337.      {
  338.         if(e>1)e--;
  339.         x=1;
  340.      }
  341.      delay_ms (ret);
  342.   }alrmH=e-1;alrmT=etqs-1;
  343. }
  344.  
  345.  
  346. //FUNCION PARA LIMPIAR VECTOR DE ALMACENAMIENTO DE NRO DE REMITENTE
  347. void inic_nrem(void)
  348. {
  349.   for (int i=0; i<=13; i++)
  350.   {
  351.  
  352.      NREM[i]=0x00;
  353.   }
  354.   inr=0x00;
  355. }
  356. void inic_pos(void)
  357. {
  358.   pos[0]=0;
  359.   pos[1]=0;
  360.   ip=0;
  361.   posi=0;
  362. }
  363.  
  364. //FUNCION PARA ENVIO DE SMS DE REPORTES
  365. void enviar_reporte(unsigned int x)
  366. {
  367.  
  368.   printf ("AT+CNMI=0\r\n");
  369.   delay_ms (ret);
  370.  
  371.   if (x==0)
  372.   {
  373.      for (int M=0; M<n; M++)
  374.      {
  375.  
  376.         printf ("AT+CMGS=%s\r\n",NUM[M]);
  377.         delay_ms (ret);
  378.         printf ("SCEMA Ex MERIDA DVD\r\n");
  379.         printf ("\r\nESTACION: %s\r\n",ETQ[0]);
  380.         printf ("Alarmas: %u/%u\r\nContactos: %u/%u\r\n",alrmH,alrmT,n,nros);
  381.         printf ("\r\nCOMANDOS ACEPTADOS:\r\nI: Info\r\nR: Reporte\r\n1: PulsoSalida1\r\n2: PulsoSalida2%c\r\n",ctrlz);
  382.         //printf ("%c\r\n",ctrlz);
  383.  
  384.         fn=11;
  385.         capturar();
  386.         delay_ms (ret);
  387.      }
  388.   }
  389.  
  390.   if (x==3)
  391.   {    
  392.  
  393.         printf ("AT+CMGS=%s\r\n",NREM);
  394.         delay_ms (ret);
  395.         printf ("SCEMA Ex MERIDA DVD\r\n");
  396.         printf ("\r\nESTACION: %s\r\n",ETQ[0]);
  397.         printf ("Alarmas: %u/%u\r\nContactos: %u/%u\r\n",alrmH,alrmT,n,nros);
  398.         printf ("\r\nCOMANDOS ACEPTADOS:\r\nI: Info\r\nR: Reporte\r\n1: PulsoSalida1\r\n2: PulsoSalida2%c\r\n",ctrlz);
  399.         //printf ("%c\r\n",ctrlz);
  400.  
  401.         fn=11;
  402.         capturar();
  403.         delay_ms (ret);
  404.   }
  405.  
  406.  
  407.   if (f1==0&&f2==0&&f3==0&&f4==0&&f5==0&&f6==0)
  408.   {
  409.  
  410.      if (x==1)
  411.      {
  412.  
  413.         printf ("AT+CMGS=%s\r\n",NREM);
  414.         delay_ms (ret);
  415.         printf ("Reporte General:\r\n\r\nTOTAL_ALARMAS=0%c\r\n",ctrlz);
  416.  
  417.         fn=11;
  418.         capturar();
  419.         delay_ms (ret);
  420.      }
  421.      if (x==2)
  422.      {
  423.         for (int M=0; M<n; M++)
  424.         {
  425.  
  426.            printf ("AT+CMGS=%s\r\n",NUM[M]);
  427.            delay_ms (ret);
  428.            printf ("Reporte General:\r\n\r\nTOTAL_ALARMAS=0%c\r\n",ctrlz);
  429.  
  430.            fn=11;
  431.  
  432.            capturar();
  433.  
  434.  
  435.            delay_ms (ret);
  436.         }
  437.      }
  438.   }
  439.  
  440.   else
  441.   {
  442.      if (x==1)
  443.      {
  444.  
  445.            printf ("AT+CMGS=%s\r\n",NREM);
  446.            delay_ms (ret);
  447.            printf ("Reporte General:\r\n\r\n");
  448.            printf ("%s=%u\r\n%s=%u\r\n%s=%u\r\n",ETQ[1],f1,ETQ[2],f2,ETQ[3],f3);
  449.            printf ("%s=%u\r\n%s=%u\r\n%s=%u%c\r\n",ETQ[4],f4,ETQ[5],f5,ETQ[6],f6,ctrlz);
  450.            //printf ("%c\r\n",ctrlz);
  451.  
  452.            fn=11;
  453.            capturar();
  454.  
  455.  
  456.            delay_ms (ret);
  457.      }
  458.      if (x==2)
  459.      {
  460.         for (int M=0; M<n; M++)
  461.         {
  462.            printf ("AT+CMGS=%s\r\n",NUM[M]);
  463.            delay_ms (ret);
  464.            printf ("Reporte General:\r\n\r\n");            
  465.            printf ("%s=%u\r\n%s=%u\r\n%s=%u\r\n",ETQ[1],f1,ETQ[2],f2,ETQ[3],f3);
  466.            printf ("%s=%u\r\n%s=%u\r\n%s=%u%c\r\n",ETQ[4],f4,ETQ[5],f5,ETQ[6],f6,ctrlz);
  467.            //printf ("%c\r\n",ctrlz);
  468.  
  469.            fn=11;
  470.  
  471.            capturar();
  472.  
  473.            delay_ms (ret);
  474.         }
  475.      }
  476.   }
  477.  
  478.   delay_ms (ret);
  479.  
  480.  
  481. }
  482.  
  483.  
  484. //FUNCION PARA IDENTIFICAR REMITENTE
  485. unsigned int ident_nrem(void)
  486. {
  487.   int cmp,res=0,k=0,j=0;
  488.   while (res==0)
  489.   {
  490.      if (NREM[k]==NUM[j][k])
  491.      {
  492.         if (k==12)
  493.         {
  494.            cmp=1; res=1;
  495.         }
  496.         else k++;
  497.      }
  498.      else
  499.      {
  500.         if (j==n)
  501.         {
  502.            cmp=0; res=1;
  503.         }
  504.         else
  505.         {
  506.            k=0;
  507.            j++;
  508.         }
  509.      }
  510.   }return (cmp);
  511. }
  512.  
  513.  
  514. //FUNCION PARA CHEQUEAR EL ESTADO DE LAS SALIDAS
  515. void check_sal(void)
  516.   {
  517.         if (alarm_salida1==1&&retardo1>TE_SALIDA1)
  518.      {
  519.         output_low (salida1);
  520.         alarm_salida1=0;
  521.         if(record==0&&alarm_salida2==0)
  522.            disable_interrupts (int_RTCC);
  523.      }
  524.  
  525.  
  526.      if (alarm_salida2==1&&retardo2>TE_SALIDA2)
  527.      {
  528.         output_low (salida2);
  529.         alarm_salida2=0;
  530.         if(record==0&&alarm_salida1==0)
  531.            disable_interrupts (int_RTCC);
  532.      }
  533.  
  534.   }
  535.  
  536.  
  537. //FUNCION PARA PROCESAR LOS SMS ENTRANTES SEGUN LA VALIDEZ DEL REMITENTE
  538. void leer_nvosms (unsigned int x)
  539.   {
  540.  
  541.  
  542.   delay_ms (ret);
  543.   fn=7;
  544.   printf ("AT+CMGR=%u\r\n",x);
  545.  
  546.  
  547.   capturar();
  548.   delay_ms (ret);
  549.  
  550.   if (ident_nrem () ==1)
  551.   {
  552.      switch (l)
  553.      {
  554.  
  555.         case 0x49:
  556.         enviar_reporte (3);
  557.  
  558.         break;
  559.  
  560.         case 0x52:
  561.         enviar_reporte (1);
  562.  
  563.         break;
  564.  
  565.         case 0x31:
  566.         if(alarm_salida1==0)
  567.         {
  568.         setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_bit);
  569.         enable_interrupts (int_RTCC);
  570.         alarm_salida1=1;
  571.         retardo1=0;
  572.         output_high (salida1);
  573.  
  574.         for (int M=0; M<n; M++)
  575.         {
  576.  
  577.            printf ("AT+CMGS=%s\r\n",NUM[M]);
  578.            delay_ms (500);
  579.            printf ("Pulso SALIDA1 activado por:\r\n%s%c\r\n",NREM,ctrlz);
  580.            //printf ("%c\r\n",ctrlz);
  581.  
  582.            fn=11;
  583.            capturar();
  584.            delay_ms (ret);  
  585.            check_sal();
  586.  
  587.         }
  588.         }
  589.         break;
  590.  
  591.         case 0x32:
  592.         if(alarm_salida2==0)
  593.         {
  594.         setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_bit);
  595.         enable_interrupts (int_RTCC);
  596.         alarm_salida2=1;
  597.         retardo2=0;
  598.         output_high (salida2);
  599.         for (int M=0; M<n; M++)
  600.         {
  601.            printf ("AT+CMGS=%s\r\n",NUM[M]);
  602.            delay_ms (500);
  603.            printf ("Pulso SALIDA2 activado por:\r\n%s%c\r\n",NREM,ctrlz);
  604.            //printf ("%c\r\n",ctrlz);
  605.  
  606.            fn=11;
  607.            capturar();
  608.            delay_ms (ret);
  609.            check_sal();
  610.  
  611.         }
  612.         }
  613.         break;
  614.  
  615.         default:
  616.         break;
  617.      }
  618.   }
  619.   l=NULL;
  620.   inic_nrem ();
  621.   delay_ms (ret);
  622.   }
  623.  
  624.  
  625. //REPORTE INDIVIDUAL DE ACTIVACION O DESACTIVACION DE ENTRADA DE ALARMA A TODOS LOS CONTACTOS
  626. void mensaje_etqX_listcontactos(unsigned int etiq,unsigned int cnd)
  627. {
  628.   if (read_eeprom(0x00)!='1')//VERIFICO QUE NO VENGA DE UN AUTO RESET
  629.   {
  630.   printf ("AT+CNMI=0\r\n");
  631.   delay_ms (ret);
  632.  
  633.   for (int M=0; M<n; M++)
  634.   {
  635.      printf ("AT+CMGS=%s\r\n",NUM[M]);
  636.      delay_ms (ret);
  637.      printf ("%s",ETQ[etiq]);
  638.      if (cnd==1){printf ("=1"); }
  639.      if (cnd==0){printf ("=0"); }
  640.      printf ("%c\r\n",ctrlz);
  641.  
  642.      fn=11;
  643.      capturar();
  644.      delay_ms (ret);
  645.   }
  646.  
  647.   fn=0;
  648.   delay_ms (5000);
  649.   printf ("AT+CNMI=2\r\n");
  650.   }
  651. }
  652.  
  653. //FUNCION PARA ENCENDER MODULO
  654. void encender_modem(void)
  655. {
  656.   output_low (pwr) ;
  657.   delay_ms (1000) ;
  658.   output_high (pwr) ;
  659.   delay_ms (2000) ;
  660.   output_low (pwr) ;
  661.   delay_ms (8000) ;
  662.   int s=0;
  663.   fn=20;
  664.   printf ("AT\r\n");
  665.   while (cap==0)
  666.      {output_high (led_senal);
  667.      delay_ms(100);
  668.      s++;
  669.      if(s==50){bloqueo(1);}
  670.      }
  671.   cap=0;
  672.   //write_eeprom(0x01,NULL);
  673.   output_low (led_senal) ;
  674. }
  675.  
  676.  
  677. //COMANDO BASICOS DE CONFIGURACION
  678. void config_modem(void)
  679. {
  680.   printf ("AT+CMGF=1\r\n");
  681.   delay_ms (ret);
  682.   printf ("AT+CNMI=0\r\n");
  683.   delay_ms (ret);
  684.   printf ("AT+CSMP=17,167,0,1\r\n");
  685.   delay_ms (ret);
  686.   printf ("ATE0\r\n");
  687.   delay_ms (ret);
  688. }
  689.  
  690. //FUNCION PRINCIPAL
  691. void main(void)
  692. {
  693.   enable_interrupts (int_RDA);
  694.   enable_interrupts (GLOBAL);
  695.  
  696.  
  697.   encender_modem ();
  698.   config_modem ();
  699.   ext_nros ();
  700.   delay_ms (500);
  701.   ext_etqs ();
  702.   delay_ms (500);
  703.   for(int p=e+1;p<=15;p++)
  704.   {
  705.   printf ("AT+CMGD=%u\r\n",p);//PARA BORRAR LOS POSIBLES MENSAJES PRESENTES DE LA POSICION 8 EN ADELANTE
  706.   delay_ms (ret);
  707.   }
  708.  
  709.   if (read_eeprom(0x00)!='1')enviar_reporte (0);//ASI VERIFICO SI VENGO DE UN AUTO RESETEO
  710.  
  711.  
  712.   fn=0;
  713.   delay_ms(5000);
  714.   printf ("AT+CNMI=2\r\n");//ACTIVAR EL AVISO DE NVOS SMS ENTRANTES
  715.  
  716.   while (TRUE)
  717.   {
  718.      check_sal();//VERIFICO ESTADO DE SALIDAS      
  719.      output_toggle (led_senal);//LED DE SEÑAL QUE PARPADEA INDICANDO ESTADO DEL SMC
  720.      delay_ms (300);
  721.  
  722.      if (sms==1)//VERIFICO SI HAY NUEVOS SMS DE ENTRADA
  723.      {
  724.         printf ("AT+CNMI=0\r\n");
  725.         posi=atoi (pos);
  726.         if (posi==e+1){leer_nvosms (posi);delay_ms (5000);printf ("AT+CMGD=%u\r\n",posi);}
  727.         if (posi>e+1){for(int q=e+1;q<=posi;q++){leer_nvosms (q);delay_ms (5000);printf ("AT+CMGD=%u\r\n",q);}}
  728.         inic_pos (); sms=0;fn=0;  delay_ms (5000);printf ("AT+CNMI=2\r\n");}
  729.  
  730.  
  731.         if (input (alrm1)==0&&f1==0)//ACTIVACION DE ALARMA 1
  732.         {  
  733.            ca1++;//RETARDO PARA EVITAR FALSAS ALARMAS
  734.               if(ca1==ret_alrm)
  735.               {
  736.               ca1=0;
  737.               f1=1;
  738.               mensaje_etqX_listcontactos (1,1);//MANDAR A ENVIAR ACTIVACION DE LA ETIQUETA 1
  739.               }
  740.         }
  741.  
  742.         if ((input (alrm1)==1&&f1==0)||(input (alrm1)==0&&f1==1))ca1=0;//DESACTIVACION DE ALARMA SIN CUMPLIRSE EL TIEMPO DE RETARDO
  743.  
  744.         if (input (alrm2)==0&&f2==0)
  745.         {  
  746.            ca2++;
  747.               if(ca2==ret_alrm)
  748.               {
  749.               ca2=0;
  750.               f2=1;
  751.               mensaje_etqX_listcontactos (2,1);
  752.               }
  753.         }
  754.  
  755.         if ((input (alrm2)==1&&f2==0)||(input (alrm2)==0&&f2==1))ca2=0;
  756.  
  757.         if (input (alrm3)==0&&f3==0)
  758.         {  
  759.            ca3++;
  760.               if(ca3==ret_alrm)
  761.               {
  762.               ca3=0;
  763.               f3=1;
  764.               mensaje_etqX_listcontactos (3,1);
  765.               }
  766.         }
  767.  
  768.         if ((input (alrm3)==1&&f3==0)||(input (alrm3)==0&&f3==1))ca3=0;
  769.  
  770.         if (input (alrm4)==0&&f4==0)
  771.         {  
  772.            ca4++;
  773.               if(ca4==ret_alrm)
  774.               {
  775.               ca4=0;
  776.               f4=1;
  777.               mensaje_etqX_listcontactos (4,1);
  778.               }
  779.         }
  780.  
  781.         if ((input (alrm4)==1&&f4==0)||(input (alrm4)==0&&f4==1))ca4=0;
  782.  
  783.         if (input (alrm5)==0&&f5==0)
  784.         {  
  785.            ca5++;
  786.               if(ca5==ret_alrm)
  787.               {
  788.               ca5=0;
  789.               f5=1;
  790.               mensaje_etqX_listcontactos (5,1);
  791.               }
  792.         }
  793.  
  794.         if ((input (alrm5)==1&&f5==0)||(input (alrm5)==0&&f5==1))ca5=0;
  795.  
  796.         if (input (alrm6)==0&&f6==0)
  797.         {  
  798.            ca6++;
  799.               if(ca6==ret_alrm)
  800.               {
  801.               ca6=0;
  802.               f6=1;
  803.               mensaje_etqX_listcontactos (6,1);
  804.               }
  805.         }
  806.  
  807.  
  808.  
  809.         if ((input (alrm6)==1&&f6==0)||(input (alrm6)==0&&f6==1))ca6=0;
  810.  
  811.  
  812.  
  813.  
  814. //////////////////////////////////////////////////////////////////////////////////
  815.  
  816.  
  817.  
  818.  
  819.  
  820.      if (f1==1||f2==1||f3==1||f4==1||f5==1||f6==1)//PARA INDICAR LA ACTIVACION DE CUALQUIER ALARMA PARA EL ENVIO DE REPORTES
  821.         hist=1;
  822.  
  823.  
  824. ////////////////////////////////////////////////////////DESACTIVACION DE ALARMAS
  825.  
  826.  
  827.      if (input (alrm1)==1&&f1==1)//
  828.      {  
  829.            ca1++;
  830.               if(ca1==ret_alrm)
  831.               {
  832.               ca1=0;
  833.               f1=0;
  834.               mensaje_etqX_listcontactos (1,0);//PARA ENVIAR AVISO DE DESACTIVACION DE ALARMA 1
  835.               }
  836.      }
  837.  
  838.      if (input (alrm2)==1&&f2==1)
  839.      {  
  840.            ca2++;
  841.               if(ca2==ret_alrm)
  842.               {
  843.               ca2=0;
  844.               f2=0;
  845.               mensaje_etqX_listcontactos (2,0);
  846.               }
  847.      }
  848.  
  849.      if (input (alrm3)==1&&f3==1)
  850.      {  
  851.            ca3++;
  852.               if(ca3==ret_alrm)
  853.               {
  854.               ca3=0;
  855.               f3=0;
  856.               mensaje_etqX_listcontactos (3,0);
  857.               }
  858.      }
  859.  
  860.      if (input (alrm4)==1&&f4==1)
  861.      {  
  862.            ca4++;
  863.               if(ca4==ret_alrm)
  864.               {
  865.               ca4=0;
  866.               f4=0;
  867.               mensaje_etqX_listcontactos (4,0);
  868.               }
  869.      }
  870.  
  871.      if (input (alrm5)==1&&f5==1)
  872.      {  
  873.            ca5++;
  874.               if(ca5==ret_alrm)
  875.               {
  876.               ca5=0;
  877.               f5=0;
  878.               mensaje_etqX_listcontactos (5,0);
  879.               }
  880.      }
  881.  
  882.      if (input (alrm6)==1&&f6==1)
  883.      {  
  884.            ca6++;
  885.               if(ca6==ret_alrm)
  886.               {
  887.               ca6=0;
  888.               f6=0;
  889.               mensaje_etqX_listcontactos (6,0);
  890.               }
  891.      }
  892.  
  893.  
  894.  
  895. ///////////////////ENVIO DE REPORTES AUTOMATICOS
  896.      if ( (input (s1)==0||input (s2)==0) && (f1==1||f2==1||f3==1||f4==1||f5==1||f6==1))
  897.      {
  898.         setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_32|RTCC_8_bit);
  899.         enable_interrupts (int_RTCC);
  900.  
  901.         if (input (s1)==0&&input (s2)==1) rep=10;        
  902.         if (input (s1)==1&&input (s2)==0) rep=20;
  903.         if (input (s1)==0&&input (s2)==0) rep=30;
  904.            record=1;
  905.         if (min>=rep&&seg==0){enviar_reporte (2); seg=0; min=0;fn=0; delay_ms(5000); printf ("AT+CNMI=2\r\n");}
  906.      }
  907.  
  908.  
  909.      if (f1==0&&f2==0&&f3==0&&f4==0&&f5==0&&f6==0&&hist==1)
  910.      {
  911.      enviar_reporte (2);
  912.      hist=0;
  913.      fn=0;
  914.      delay_ms(5000);
  915.      printf ("AT+CNMI=2\r\n");
  916.      }
  917.       if ( (input (s1)==1&&input (s2)==1)|| (f1==0&&f2==0&&f3==0&&f4==0&&f5==0&&f6==0))
  918.      {
  919.      record=0;
  920.      uptime=0;seg=0; min=0;
  921.      if(alarm_salida1==0&&alarm_salida2==0)
  922.         disable_interrupts (int_RTCC);
  923.  
  924.      }
  925.  
  926. ///////////
  927.  
  928.  
  929.   if (read_eeprom(0x00)=='1')
  930.   {
  931.   enviar_reporte (2);fn=0;delay_ms(5000);printf ("AT+CNMI=2\r\n");write_eeprom(0x00,NULL);
  932.   }
  933.   }
  934. }

 
Mod: Los codigos deben ir en etiquetas GeSHi
« Última modificación: 26 Abril 2015, 22:51 pm por engel lex » En línea

engel lex
Moderador Global
***
Desconectado Desconectado

Mensajes: 15.514



Ver Perfil
Re: software en lenguaje c
« Respuesta #3 en: 26 Abril 2015, 22:56 pm »

coloca los errores exactamente como los da el compilador...

error de la linea 51
Código
  1. reset_cpu();

no tienes tal función en el código...

un código de 1000 lineas se asume largo XD

sobre pastebin... esto es pastebin.com
En línea

El problema con la sociedad actualmente radica en que todos creen que tienen el derecho de tener una opinión, y que esa opinión sea validada por todos, cuando lo correcto es que todos tengan derecho a una opinión, siempre y cuando esa opinión pueda ser ignorada, cuestionada, e incluso ser sujeta a burla, particularmente cuando no tiene sentido alguno.
T. Collins

Desconectado Desconectado

Mensajes: 206


Ver Perfil
Re: software en lenguaje c
« Respuesta #4 en: 26 Abril 2015, 23:01 pm »

Quita los nombres del código  :-\
« Última modificación: 26 Abril 2015, 23:04 pm por T. Collins » En línea

GAWAIN2010

Desconectado Desconectado

Mensajes: 5


Ver Perfil
Re: software en lenguaje c
« Respuesta #5 en: 27 Abril 2015, 01:34 am »

Buenas tardes nuevamente:

Los errores que aparecen al intentar compilar son los siguientes:

***Error 51 "ALARMA GSM.c" Line 29 (4,7): A numeric expression must appear here

***Error 51 "ALARMA GSM.c" Line 31 (14,17): A numeric expression must appear here

***Error 51 "ALARMA GSM.c" Line 33 (4,7): A numeric expression must appear here

Este error se repite y observo que espara toda la declaracion de variables.

Tambien aparece una vez:

***Error 76 "ALARMA GSM.c" Line 46 (77,78): A numeric expression must appear here

Otro error que se repite es:

***Error 12 "ALARMA GSM.c" Line 70 (12,13): A numeric expression must appear here

Nuevamente aprecio su ayuda.

Saludos,

GAWAIN
En línea

engel lex
Moderador Global
***
Desconectado Desconectado

Mensajes: 15.514



Ver Perfil
Re: software en lenguaje c
« Respuesta #6 en: 27 Abril 2015, 02:54 am »

tu codigo se llama "ALARMA GSM.c"?

porque hay un montón de funciones declaradas que no aparecen en el código
En línea

El problema con la sociedad actualmente radica en que todos creen que tienen el derecho de tener una opinión, y que esa opinión sea validada por todos, cuando lo correcto es que todos tengan derecho a una opinión, siempre y cuando esa opinión pueda ser ignorada, cuestionada, e incluso ser sujeta a burla, particularmente cuando no tiene sentido alguno.
GAWAIN2010

Desconectado Desconectado

Mensajes: 5


Ver Perfil
Re: software en lenguaje c
« Respuesta #7 en: 27 Abril 2015, 03:12 am »

Si, ese fue el nombre que coloque al iniciar con el PIC WIZARD.

Debo aclararte que el procedimiento que segui fue el siguiente (lo coloco porque recuerda que apenas estoy comenzando):

Arranque el CCS y oprimi el PIC WIZARD, le coloque el nombre que me pedia como ALARMA GSM y cuando coloco el encabezado en la pagina, abajo coloque el codigo del programa que me hicieron llegar.

Aprecio tu ayuda.

Saludos,

GAWAIN
En línea

engel lex
Moderador Global
***
Desconectado Desconectado

Mensajes: 15.514



Ver Perfil
Re: software en lenguaje c
« Respuesta #8 en: 27 Abril 2015, 04:19 am »

corrijo... la función si está definida...

revisando el código bien veo variables no definidas como n en la linea 306, me imagino que por eso es...
En línea

El problema con la sociedad actualmente radica en que todos creen que tienen el derecho de tener una opinión, y que esa opinión sea validada por todos, cuando lo correcto es que todos tengan derecho a una opinión, siempre y cuando esa opinión pueda ser ignorada, cuestionada, e incluso ser sujeta a burla, particularmente cuando no tiene sentido alguno.
SrCooper

Desconectado Desconectado

Mensajes: 137


Bazinga!


Ver Perfil
Re: software en lenguaje c
« Respuesta #9 en: 28 Abril 2015, 17:53 pm »

revisando el código bien veo variables no definidas como n en la linea 306, me imagino que por eso es...

La variable n está definida en la linea 14. Además, la función inic_nrem(void) está definida dos veces en la línea 34. No se me ocurre que más puede ser, habría que revisarlo cuidadosamente para encontrar los errores.

De todas maneras creo que la mejor manera de detectar un error sería probar a compilarlo con otro compilador (el gcc por ejemplo) y comparar el mensaje de error con el del CCS.

Un saludo

PD: Por cierto, no utilices void main() por favor. Utiliza int main() en su lugar.
« Última modificación: 28 Abril 2015, 17:55 pm por SrCooper » En línea

Páginas: [1] 2 Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines