rpp_sci_printf((const char*)"================================\r\n");
rpp_sci_printf((const char*)"--> ");
+ int16_t raw = 0;
uint8_t input = 0;
uint8_t buff_index = 0;
boolean_t flush = FALSE;
while(TRUE) {
// Get one character from the user
- input = rpp_sci_getc();
+ raw = rpp_sci_getc();
+ if(raw == FAILURE) {
+ vTaskDelay(100 / portTICK_RATE_MS);
+ continue;
+ }
+ input = (uint8_t)raw;
// Backspace and Delete
if(input == 8 || input == 127) {
</tool>
</toolChain>
</folderInfo>
+ <fileInfo id="cdt.managedbuild.toolchain.gnu.base.520906199.1983895916" name="rpp_posix.c" rcbsApplicability="disable" resourcePath="lib/rpp/rpp_posix.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.base.814685508.1381444926">
+ <tool id="cdt.managedbuild.tool.gnu.c.compiler.base.814685508.1381444926" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.base.814685508"/>
+ </fileInfo>
<sourceEntries>
<entry excluding="src|lib" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
- <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="lib"/>
+ <entry excluding="rpp/rpp_posix.c|os/rpp_support.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="lib"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/rpp/src/rpp/rpp.c</locationURI>
</link>
+ <link>
+ <name>lib/rpp/rpp_posix.c</name>
+ <type>1</type>
+ <locationURI>PARENT-2-PROJECT_LOC/os/6.0.4_posix/src/rpp/rpp_posix.c</locationURI>
+ </link>
<link>
<name>lib/rpp/sci.c</name>
<type>1</type>
#include "rpp/rpp.h"
#include <stdlib.h>
-#if rppCONFIG_DRV == 0
-#include <stdio.h> // printf()
-#define rpp_sci_printf printf
+#if defined(FREERTOS_POSIX)
+#include "lib/rpp/rpp_posix.c"
#endif
#define FREQ_MILLIS 3000
#define FREERTOS_VERSION_NUMBER_MINOR 0
#define FREERTOS_VERSION_NUMBER_REV 4
+#define FREERTOS_POSIX 1
+
#include "os/FreeRTOS.h"
#include "os/task.h"
#include "os/semphr.h"
* This function will wait until a byte is available in the SCI input buffer if
* it is empty.
*
- * @return The byte read from the SCI input buffer.
+ * @note The byte is promoted to an int16_t in order to accommodate for EOF/-1
+ * if an error occurs. This is in order to conform with C getc, but should never
+ * happen in current implementation.
+ *
+ * @return [0-255] The byte read from the SCI input buffer.
+ * [ < 0 ] If and error occurred.
*/
-uint8_t rpp_sci_getc();
+int16_t rpp_sci_getc();
}
-uint8_t rpp_sci_getc()
+int16_t rpp_sci_getc()
{
uint8_t result = 0;
#if rppCONFIG_DRV == 1
- drv_sci_receive(1, &result, portMAX_DELAY);
+ if(drv_sci_receive(1, &result, portMAX_DELAY) == FAILURE) {
+ return FAILURE;
+ }
#endif
- return result;
+ return (int16_t)result;
}
#include "rpp/rpp.h"
#if rppCONFIG_INCLUDE_SDR == 1
-#include <stdio.h> // vsnprintf() & (printf() & putchar())
+#include <stdio.h> // vsnprintf()
#include <ctype.h> // isprint()
#include <string.h> // strncmp()
#include <stdarg.h> // va_start, va_end
#if rppCONFIG_DRV == 1
#include "drv/drv.h"
-#else
+#elif defined(FREERTOS_POSIX)
#include <stdlib.h> // malloc()
-#define rpp_sci_putc putchar
-#define rpp_sci_printf printf
+#include "lib/os/rpp_support.c"
#endif
static const char* prompt = "--> ";
while(TRUE) {
// Get one character from the user
- #if rppCONFIG_DRV == 1
if(rpp_sci_read_nb(1, &input) != SUCCESS) {
- #else // FIXME: In POSIX simulation this line doesn't work.
- if(rpp_sci_read_nb(1, &input) != SUCCESS) {
- #endif
- vTaskDelay(10);
+ vTaskDelay(100 / portTICK_RATE_MS);
continue;
}
// Stop flushing if one character is received
if(show_flushing) {
rpp_sdr_show(FALSE);
- vTaskDelay(10);
+ vTaskDelay(100 / portTICK_RATE_MS);
rpp_sci_printf("%s", newline);
rpp_sci_printf("%s", prompt);
continue;
memory_size = RPP_SDR_ADDR_END - RPP_SDR_ADDR_START + 1;
memory_start = (uint8_t*)RPP_SDR_ADDR_START;
memory_end = (uint8_t*)RPP_SDR_ADDR_END;
- #else
+ #elif defined(FREERTOS_POSIX)
memory_size = 1024*1024; // Allocate 1MB for test
memory_start = (uint8_t*)malloc(memory_size);
memory_end = (uint8_t*)(memory_start + memory_size - 1);
return FAILURE;
}
+ // Don't even try if memory is full
+ if(memory_current == memory_end) {
+ return FAILURE;
+ }
+
/// Format user string
char str[MAX_BUFFER_LEN];
int length = -1;