desmondlai
New Member
i having problem how to write a comparison program for my gsm modem that replying (10 79 75 13) in decimal with OK in characters ...
#include <htc.h>
#include <stdio.h>
#include "usart.h"
#include "delay.h"
#include <string.h>
int main(void)
{
//Initialize PORTD
//PD0 as Output
TRISB=0b00000000;
TRISC=0b10000000;
INTCON=0; // purpose of disabling the interrupts.
init_comms(); // set up the USART - settings defined in usart.h
char input[80] ;
int i;
PORTB =0B11111111; //PORTB0 = HIGH
DelayUs(500);
PORTB =0B00000000; //PORTB0 = LOW
DelayUs(300);
printf("at\r");
gets(input);
i= strcmp(input,"OK");******* suppose before and after OK will have (nl) and (cr).how to include the (nl)(cr) into the comparison?
if (!i)
{
RB1=1;
DelayUs(500);
RB1=0;
DelayUs(300);
printf("at+cgmm\r");
}
return 0;
}
#include <htc.h>
#include <stdio.h>
#include "usart.h"
#include "delay.h"
#include <string.h>
int main(void)
{
//Initialize PORTD
//PD0 as Output
TRISB=0b00000000;
TRISC=0b10000000;
INTCON=0; // purpose of disabling the interrupts.
init_comms(); // set up the USART - settings defined in usart.h
char input[80] ;
int i;
PORTB =0B11111111; //PORTB0 = HIGH
DelayUs(500);
PORTB =0B00000000; //PORTB0 = LOW
DelayUs(300);
printf("at\r");
gets(input);
i= strcmp(input,"OK");******* suppose before and after OK will have (nl) and (cr).how to include the (nl)(cr) into the comparison?
if (!i)
{
RB1=1;
DelayUs(500);
RB1=0;
DelayUs(300);
printf("at+cgmm\r");
}
return 0;
}