Asynchronous (Non-blocking) Serial Communication library with variable length software ring buffer (FIFO). You can use RawSerial Library's primary method. Operability confirmed on mbed 2.0.

Dependencies:   FIFO

Dependents:   Brute_TS_Controller_2018_11

Revision:
8:7390f9bb28d3
Parent:
6:08e3b1bba0ac
Child:
9:709719dddd3e
--- 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){