Vincent Wochnik / CellularUSBModem

Dependencies:   CellularModem USBHost

Fork of CellularUSBModem by mbed official

Revision:
5:ee78021fb56a
Parent:
1:6547cd17fdb6
diff -r e830600cb2e3 -r ee78021fb56a serial/usb/USBSerialStream.cpp
--- a/serial/usb/USBSerialStream.cpp	Fri Oct 18 09:19:53 2013 +0000
+++ b/serial/usb/USBSerialStream.cpp	Fri Apr 11 09:33:23 2014 +0000
@@ -213,7 +213,7 @@
 }
 
 void USBSerialStream::writeable() //Callback from m_serial when new space is available
-{
+/*{
   if(m_outBuf.isEmpty())
   {
     m_serialTxFifoEmpty = true;
@@ -233,4 +233,24 @@
   {
     m_spaceSphre.release(); //Force exiting the waiting state
   }
+}*/{
+  if(m_outBuf.isEmpty())
+  {
+    m_serialTxFifoEmpty = true;
+  }
+  else if (m_serial.writeable())
+  {    
+    m_serialTxFifoEmpty = false;
+    while(m_serial.writeable() && !m_outBuf.isEmpty())
+    {
+      uint8_t c;
+      m_outBuf.dequeue(&c);
+      m_serial.putc((char)c);
+    }
+    m_serial.writePacket(); //Start packet write
+  }
+  if(!m_outBuf.isFull())
+  {
+    m_spaceSphre.release(); //Force exiting the waiting state
+  }
 }