91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .c
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-06-03
  • 語言: C/C++
  • 標簽: gprs??

資源簡介

gprs接收源程序代碼,在mini2440上實現(xiàn)。 基于arm的gprs程序,語言是c語言,可用作嵌入式設備。

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
int?open_port(int?fdint?comport);
int?set_opt?(int?fd?int?nSpeed?int?nBits?char?nEvent?int?nStop)?;

int?main(void)
{
int?fd;
int?nwritenreadi=0?;
char?red[512]buf[1024]?=?{‘\0‘}?;
char?*pcon?*pr;

if((fd=open_port(fd1))<0)
{
perror(“open_port?error“);
return?-1;
}
if((i=set_opt(fd96008‘N‘1))<0)
{
perror(“set_opt?error“);
return;
}
//測試AT命令
write(fd“AT\r“3);
sleep(2);
nread=read(fdred256);//讀串口
if(strstr(red“OK“)?==?NULL)
printf(“the?AT?is?faule!!\n“);
printf(“nread=%d%s\n“nreadred);

//測試AT+CSQ命令,檢查網(wǎng)絡信號強度和SIM卡情況(**,##)
write(fd“AT+CSQ\r“7);
sleep(2);
nread=read(fdred256);
if(strstr(red“OK“)?==?NULL)
printf(“the?AT+CSQ?is?faule!!\n“);
printf(“nread=%s\n“red);

//接收短信主動提示
write(fd“AT+CNMI=11\r“12)?;
sleep(2)?;
nread=read(fdred256);
if(strstr(red“OK“)?==?NULL)
printf(“the?AT+CNMI=11?is?faule!!\n“);
printf(“nread=%s\n“red);

//接收短信從串口輸出
write(fd“AT+CSMS=1\r“10)?;
sleep(2)?;
nread=read(fdred256);
if(strstr(red“OK“)?==?NULL)
printf(“the?AT+CSMS=1?is?faule!!\n“);
printf(“nread=%s\n“red);

write(fd“AT+CNMI=22\r“12)?;
sleep(2)?;
nread=read(fdred256);
if(strstr(red“OK“)?==?NULL)
printf(“the?AT+CNMI=22?is?faule!!\n“);
printf(“nread=%s\n“red);

while(1)
{
i?=?0;
buf[i]?=?‘\0‘;
nread=read(fdred512);
if(nread)
{
printf(“read?content?=?%s\n“red);
pcon?=?pr?=?red;
while(pr)
{
????while(*pcon?!=?‘\012‘)
{
????pcon++;
pr++;
}
????????????????pcon++;
pr++;
while(*pr?!=?‘\n‘?&&?*pr?!=?‘\r‘)
{
????pr++;
}
break;
}
printf(“MSG:?“);
for(;?pcon?!=?pr;?pcon++)
{
buf[i++]?=?*pcon;
????printf(“%c“?*pcon);
}
????????????printf(“\n“);
buf[i]?=?‘\0‘;

printf(“buf:?%s\n“?buf);

if(strlen(buf)?==?1)
{
????if(buf[0]?>=?‘1‘?&&?buf[0]?<=?‘9‘?||?buf[0]?==?‘A‘)
{
????printf(“Send:?%c\n“?buf[0]);
}
}
}

}
return?0;
}
int?open_port(int?fdint?comport)
{
char?*dev[]={“/dev/ttyS0““/dev/ttyS1““/dev/ttyS2“};
long?vdisable;
//O_NOCTTY?標志用于通知Linux?系統(tǒng),這個程序不會成為對應這個端口的控制終端。
//O_NDELAY?標志通知Linux?系統(tǒng),這個程序不關心DCD?信號線所處的狀態(tài)(端口的另一端是否激活或者停止)。
if

評論

共有 條評論