tetete

Dependencies:   FIFO

Files at this revision

API Documentation at this revision

Comitter:
babylonica
Date:
Sat Jun 17 11:44:36 2017 +0000
Parent:
7:f068461b3ddf
Child:
9:709719dddd3e
Commit message:
FIFO Buffer Update.; Bug Fixed.

Changed in this revision

AsyncSerial.cpp Show annotated file Show diff for this revision Revisions of this file
AsyncSerial.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/AsyncSerial.cpp	Sat Jun 17 09:23:23 2017 +0000
+++ b/AsyncSerial.cpp	Sat Jun 17 11:44:36 2017 +0000
@@ -4,9 +4,10 @@
  @brief	 	Asynchronous (Non-brocking) Serial Communication library with variable length software ring buffer (FIFO). You can use also RawSerial Library's method. You can set the baudrate of the serial communication when instantiating.
  
  @author	T.Kawamura
- @version	1.1
+ @version	1.2
  @date		2017-03-29	T.Kawamura	Written for C++/mbed.
  @date		2017-03-30	T.Kawamura	Bug Fixed: Cannot use format(), baud().
+ @date		2017-06-17	T.Kawamura	Update: FIFO Buffer Fixed.
  
  @see 
  Copyright (C) 2017 T.Kawamura.
@@ -71,44 +72,32 @@
 	return (int)fifo_rx.peek();
 }
 
-int AsyncSerial::putc(int c){
-	int status;
-
+void AsyncSerial::putc(int c){
 	if( Is_Serial_Sending ){
-		status = fifo_tx.put((uint8_t)c);
-		if( status != 0 ){
-			return 1;
-		}else{
-			return 0;
-		}
+		fifo_tx.put((uint8_t)c);
 	}else{
 		Is_Serial_Sending = true;
 		RawSerial::putc(c);
 	}
-	return 1;
+	return;
 }
 
-int AsyncSerial::puts(const char *str){
+void AsyncSerial::puts(const char *str){
 	uint8_t temp;
-	int status = 0;
 
 	for(uint32_t i = 0; i < strlen(str); i++){
 		temp = (uint8_t)str[i];
-		status = fifo_tx.put(temp);
+		fifo_tx.put(temp);
 	}
 
 	if( !Is_Serial_Sending ){
 		Is_Serial_Sending = true;
 		RawSerial::putc((int)fifo_tx.get());
 	}
-
-	if( status == 0 ){
-		return 0;
-	}
 	
 	AsyncSerial::putc('\r');
 	AsyncSerial::putc('\n');
-	return 1;
+	return;
 }
 
 int AsyncSerial::printf(const char *format, ...){
@@ -134,14 +123,13 @@
 	}
 
 	va_end(arg);
-	wrote_length = AsyncSerial::write((uint8_t*)string_buffer, wrote_length);
+	AsyncSerial::write((uint8_t*)string_buffer, wrote_length);
 	
-	return (uint16_t)wrote_length;
+	return wrote_length;
 }
 
 int AsyncSerial::write(const uint8_t *buffer, int length){
 	uint8_t temp;
-	int status;
 	
 	if ( length < 1 ){
 		return 0;
@@ -149,7 +137,7 @@
 
 	for(uint32_t i = 0; i < length; i++){
 		temp = (uint8_t)buffer[i];
-		status = fifo_tx.put(temp);
+		fifo_tx.put(temp);
 	}
 
 	if( !Is_Serial_Sending ){
@@ -157,11 +145,7 @@
 		RawSerial::putc((int)fifo_tx.get());
 	}
 
-	if( status == 0 ){
-		return 0;
-	}
-
-	return 1;	
+	return 1;
 }
 
 void AsyncSerial::flush(void){
--- a/AsyncSerial.hpp	Sat Jun 17 09:23:23 2017 +0000
+++ b/AsyncSerial.hpp	Sat Jun 17 11:44:36 2017 +0000
@@ -4,10 +4,10 @@
  @brief	 	Asynchronous (Non-brocking) Serial Communication library with variable length software ring buffer (FIFO). You can use also RawSerial Library's method. You can set the baudrate of the serial communication when instantiating.
  
  @author	T.Kawamura
- @version	1.1
+ @version	1.2
  @date		2017-03-29	T.Kawamura	Written for C++/mbed.
  @date		2017-03-30	T.Kawamura	Bug Fixed: Cannot use format(), baud().
-
+ @date		2017-06-17	T.Kawamura	Update: FIFO Buffer Fixed.
  @see 
  Copyright (C) 2017 T.Kawamura.
  Released under the MIT license.
@@ -92,18 +92,16 @@
 	/**
 		 @brief	Put 1byte to the AsyncSerial port.
 		 @param	data	A Data for put
-		 @retval	0	Error.
-		 @retval	1	Success.
+		 @return		Nothing.
 	*/
-	virtual int putc(int c);
+	virtual void putc(int c);
 
 	/**
 		 @brief	Write a string with new line. The string must be NULL terminated.
 		 @param	*str	A String for write (Must be NULL terminated).
-		 @retval	0	Error.
-		 @retval	1	Success.
+		 @return		Nothing.
 	*/
-	virtual int puts(const char *str);
+	virtual void puts(const char *str);
 
 	/**
 		 @brief	Write a formatted string to the AsyncSerial port.