我在Sim300上工作,试图通过串行通信在atmega16上接收短信。当我从我的手机向*23#调制解调器发送“\r\n+CMGR:\s”短信时,gsm在串口上发送“\r\n+CMGR:\s”recs\r\n*23#\r\n\r\nOK\r\n“、"+919762148043”、“14/03/13 23:04:32+22”\r\n*23#\r\n\r\nOK\r\n作为响应。我是在atmega16上得到这些数据的,但是只有“\r\n+CMGR:\s”rec-s*23#“”,"+919762148043",“14/03/13”,23:04:32+22“\r”,在这里,“*23#”是我的实际短信,我对"23“很感兴趣。我的固件看起来像这样,
while(Serial.available())
{
char tempChar = Serial.read();
if(tempChar == '+')
{
isPreSms = true;
lcd.print('+');
}
else if((tempChar == '\r') && (isPreSms == true))
{
isPreSms = false;
lcd.print('r');
}
else if(tempChar == '*')
{
digitalWrite(OKLed, HIGH);
isSms = true;
lcd.print('*');
}
else if((tempChar == '#') && (isSms == true))
{
digitalWrite(powerLed, HIGH);
isSms = false;
lcd.print(sms);
}
else if(isSms)
{
digitalWrite(alertLed, HIGH);
sms += tempChar;
}
}
lcd.print('@');
}我期待"+++r*23@“作为液晶显示器的输出。我已经检查过了,它接收'+‘以及'\r’而不是'*‘和更远。我被困在这里了,请帮帮忙,出什么事了。
发布于 2014-04-10 14:11:30
现在我解决了。串行缓冲区的大小存在问题。我把它的大小增加到了128个字节,现在它可以正常工作了。
https://stackoverflow.com/questions/22387169
复制相似问题