#define CMDIO_BUFFER_H_
#define MAX_BUFFER_LEN 128
+#define errBUFFER_NOT_INITIALIZED -6
#include "cmd_proc.h"
#include "FreeRTOS.h"
#include "os_queue.h"
#include "os_semphr.h"
+#include "sci.h"
typedef struct {
*/
void initIoBuffer();
-/** Print string into an output buffer. Let it be blocking or nonblocking in case the buffer is full.
- * @param[in] string String to be printed into buffer
- * @param[in] length number of characters to be printed
- * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
- * @return pdPASS when OK; errQUEUE_FULL when buffer is full and ran out of block time.
- */
-portBASE_TYPE printToOutputBuffer(const uint8_t * string, uint32_t length, portTickType ticks);
-
-/** Print string into an input buffer. Let it be blocking or nonblocking in case the buffer is full.
- * @param[in] string String to be printed into buffer
+/** Print string into an output buffer in a not blocking way.
+ * @param[in] string String to be printed into output buffer
* @param[in] length number of characters to be printed
- * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
- * @return pdPASS when OK; errQUEUE_FULL when buffer is full and ran out of block time.
- */
-portBASE_TYPE printToInputBuffer(const uint8_t * string, uint32_t length, portTickType ticks);
-
-/** Read character from an output buffer. Let it be blocking or nonblocking in case the buffer is empty.
- * @param[out] ch Character read from buffer
- * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is empty. portMAX_DELAY can be used.
- * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time.
+ * @return pdPASS when OK; errQUEUE_FULL when buffer is full, errBUFFER_NOT_INITIALIZED when initIoBuffer function was not called before
*/
-portBASE_TYPE readFromOutputBuffer(uint8_t * ch, portTickType ticks);
+portBASE_TYPE print(const uint8_t * string, uint32_t length);
-/** Read character from an input buffer. Let it be blocking or nonblocking in case the buffer is empty.
+/** Read character from an input buffer in a blocking way
* @param[out] ch Character read from buffer
- * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
- * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time.
+ * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time, errBUFFER_NOT_INITIALIZED when initIoBuffer function was not called before.
*/
-portBASE_TYPE readFromInputBuffer(uint8_t * ch, portTickType ticks);
+portBASE_TYPE read(uint8_t * ch);
/** Read character from a buffer. Let it be blocking or nonblocking in case the buffer is empty.
* @param[in] buffer Pointer to buffer from which will be read.
* @param[out] ch Character read from buffer
- * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is empty. portMAX_DELAY can be used.
- * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time.
+ * @return pdPASS when OK; errQUEUE_EMPTY when buffer is empty and ran out of block time, errBUFFER_NOT_INITIALIZED when initIoBuffer function was not called before.
*/
-portBASE_TYPE read(tBuffer* buffer, uint8_t * ch, portTickType ticks);
+portBASE_TYPE genericRead(tBuffer* buffer, uint8_t * ch);
/** Print string to a buffer. Let it be blocking or nonblocking in case the buffer is full.
* @param[in] buffer Pointer to buffer from which will be read.
* @param[in] string String to be printed into buffer
* @param[in] length number of characters to be printed
- * @param[in] ticks Number of FreeRTOS's ticks to block task, when buffer is full. portMAX_DELAY can be used.
- * @return pdPASS when OK; errQUEUE_FULL when buffer is full and ran out of block time.
+ * @return pdPASS when OK; errQUEUE_FULL when buffer is full and ran out of block time, errBUFFER_NOT_INITIALIZED when initIoBuffer function was not called before.
*/
-portBASE_TYPE print(tBuffer* buffer, const uint8_t * string, uint32_t length, portTickType ticks);
+portBASE_TYPE genericPrint(tBuffer* buffer, const uint8_t * string, uint32_t length);
/** Makes input buffer empty
+ * @return pdPass when success, errBUFFER_NOT_INITIALIZED when initIoBuffer function was not called before
*/
-void clearInputBuffer();
+portBASE_TYPE clearInputBuffer();
/** Makes output buffer empty
+ * @return pdPass when success, errBUFFER_NOT_INITIALIZED when initIoBuffer function was not called before
*/
-void clearOutputBuffer();
+portBASE_TYPE clearOutputBuffer();
/** Makes buffer empty
* @param[in] buffer Buffer to be cleared
+ * @return pdPass when success, errBUFFER_NOT_INITIALIZED when initIoBuffer function was not called before
*/
-void clearBuffer(tBuffer * buffer);
+portBASE_TYPE clearBuffer(tBuffer * buffer);
/** Puts character into output buffer. Is blocking, when buffer is full.
* @param[in] cmd_io IO stack pointer
* @param[in] ch Character to be printed
* @return 1 when succes, 0 when fail
*/
-int buf_putc(cmd_io_t *cmd_io, int ch);
+int tisci_putc(cmd_io_t *cmd_io, int ch);
/** Gets character from input buffer, is blocking when buffer is empty.
* @param[in] cmd_io IO stack pointer
* @return read character
*/
-int buf_getc(cmd_io_t *cmd_io);
+int tisci_getc(cmd_io_t *cmd_io);
/** Writes string into output buffer, is blocking when buffer is full.
* @param[in] cmd_io IO stack pointer
* @param[in] count Number of character to be written
* @return number of written characters
*/
-int buf_write(cmd_io_t *cmd_io, const void *buf, int count);
+int tisci_write(cmd_io_t *cmd_io, const void *buf, int count);
/** Reads string from input buffer, is blocking when buffer is empty.
* @param[in] cmd_io IO stack pointer
* @param[in] count Number of character to be read
* @return number of read characters
*/
-int buf_read(cmd_io_t *cmd_io, void *buf, int count);
+int tisci_read(cmd_io_t *cmd_io, void *buf, int count);
#endif /* CMDIO_BUFFER_H_ */