我发现了我的主要问题。现在我将修复旧的 SIM900 库。
旧代码:
/*
* Sent the AT command.
*/
softuart_puts_P( "Transmit" );
SIM900_transmit( "AT\r" );
softuart_puts_P( " completed\r\n" );
/*
* Wait until SIM900 answers back.
*/
while ( uart_available() == 0 )//BUG: Loop in a loop(receive has one) caused chaos.
{
/*
* Sent the AT command.
*/
softuart_puts_P( "Received: [" );
cString answer = newEmptyString();
SIM900_receive( &answer );
softuart_puts( answer );
softuart_puts_P( "]\r\n" );
deleteString( &answer );
}
新代码
/*
* Sent the AT command.
*/
softuart_puts_P( "Transmit" );
SIM900_transmit( "AT\r" );
softuart_puts_P( " completed\r\n" );
/*
* Wait until SIM900 answers back.
*/
while ( uart_available() == 0 );// TODO: Put timeout in case SIM900 is switched off.
/*
* Sent the AT command.
*/
softuart_puts_P( "Received: [" );
cString answer = newEmptyString();
SIM900_receive( &answer );
softuart_puts( answer );
softuart_puts_P( "]\r\n" );
deleteString( &answer );
这完成了工作:while ( uart_available() == 0 );
谢谢你的帮助。