Fehlte noch ...:
Testprog.c
Code:
/*****************************************************************************/
// Includes:
#include "RP6M256Lib.h" // The RP6 M256 Library.
// Always needs to be included!
/*****************************************************************************/
// Variables:
// Reception buffer for the function getInputLine_WIFI():
char receiveBufferWifi[UART_RECEIVE_BUFFER_SIZE_WIFI + 1];
/*****************************************************************************/
// WIFI receive functions:
/**
* Get chars of an input line from the WIFI.
*
* Returns 0 (false), if the WIFI receive buffer is empty
* OR a character of the input line has been received.
* Returns 1, if the whole input line has been received
* (with a "new line" character at the end).
* Returns 2, if the WIFI receive buffer overflows.
* The input line is stored in the receiveBufferWifi array.
*
*/
uint8_t getInputLine_WIFI(void)
{static uint16_t buffer_pos = 0;
if(getBufferLength_WIFI()) {
receiveBufferWifi[buffer_pos] = readChar_WIFI();
if((receiveBufferWifi[buffer_pos] == '\n')
|| (receiveBufferWifi[buffer_pos] == '\r')) {
receiveBufferWifi[buffer_pos] = '\0';
buffer_pos = 0;
return 1;
}
else if(buffer_pos >= UART_RECEIVE_BUFFER_SIZE_WIFI) {
receiveBufferWifi[UART_RECEIVE_BUFFER_SIZE_WIFI] = '\0';
buffer_pos = 0;
return 2;
}
buffer_pos++;
}
return 0;
}
/**
* Get a complete input line from the WIFI.
*
* This function waits for a whole input line from the WIFI.
* The input line is stored in the receiveBuffer array.
* The function is blocking until one of the two following
* conditions occurs:
* - A "new line" character has been received at the end of
* the input line.
* - The WIFI receive buffer overflows.
*
*/
void enterString_WIFI(void)
{
while(!getInputLine_WIFI());
}
/*****************************************************************************/
// Main function - The program starts here:
int main(void)
{
initRP6M256(); // Always call this first! The Processor will not work
// correctly otherwise.
initLCD(); // Initialize the LC-Display (LCD)
// Always call this before using the LCD!
setLEDs(0b0000);
clearLCD(); // Clear the whole LCD Screen
/*****************************************************************************/
// Main test program:
while(true)
{
writeString_P_WIFI("\n\n");
writeString_P_WIFI("\n|============================|");
writeString_P_WIFI("\n| WIFI: Input a test string |\n");
enterString_WIFI();
clearLCD();
writeStringLCD(receiveBufferWifi);
mSleep(10000);
writeString_P_WIFI("\n\n");
}
/*****************************************************************************/
// End of main:
return 0;
}
Lesezeichen