Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Socket USBHostWANDongle lwip-sys lwip
Dependents: VodafoneUSBModemHTTPClientTest VodafoneUSBModemNTPClientTest VodafoneUSBModemSMSTest VodafoneUSBModemUSSDTest ... more
Fork of VodafoneUSBModem_bleedingedge by
Diff: serial/usb/USBSerialStream.cpp
- Revision:
- 83:897a0de9d668
- Parent:
- 62:6f42a974eea6
- Child:
- 95:84f01d280c9b
diff -r ab4d6263f25c -r 897a0de9d668 serial/usb/USBSerialStream.cpp
--- a/serial/usb/USBSerialStream.cpp Tue Jan 29 13:49:23 2013 +0000
+++ b/serial/usb/USBSerialStream.cpp Tue Mar 05 14:54:15 2013 +0000
@@ -17,6 +17,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+
+
#define __DEBUG__ 0
#ifndef __MODULE__
#define __MODULE__ "USBSerialStream.cpp"
@@ -28,6 +30,29 @@
#include "USBSerialStream.h"
+// XXX ashley's debug
+void printBuffer(uint8_t* buf, int len, bool readIn) {
+
+ if(len<0) {
+ return;
+ }
+
+ if(readIn) {
+ printf("Read(%d): '",len);
+ } else {
+ printf("Writing(%d): '",len);
+ }
+ for(int i=0; i<len; i++) {
+ if(buf[i]==0x0a) {
+ putchar('N');
+ } else if(buf[i]==0x0d) {
+ putchar('R');
+ } else {
+ putchar(buf[i]);
+ }
+ }
+ printf("'\r\n");
+}
USBSerialStream::USBSerialStream(IUSBHostSerial& serial) : m_serial(serial), m_serialTxFifoEmpty(true),
m_availableSphre(1), m_spaceSphre(1), m_inBuf()
@@ -46,6 +71,7 @@
//0 for non-blocking (returns immediately), -1 for infinite blocking
/*virtual*/ int USBSerialStream::read(uint8_t* buf, size_t* pLength, size_t maxLength, uint32_t timeout/*=osWaitForever*/)
{
+ uint8_t *bufPointerCopy = buf;
DBG("Trying to read at most %d chars", maxLength);
int ret = waitAvailable(timeout);
if(ret)
@@ -56,7 +82,8 @@
int a = available(); //Prevent macro issues
int readLen = MIN( a, maxLength );
*pLength = readLen;
-
+
+
setupReadableISR(false);
while(readLen--)
{
@@ -64,7 +91,8 @@
buf++;
}
setupReadableISR(true);
- DBG("Read %d chars successfully", *pLength);
+ //printBuffer(bufPointerCopy,*pLength,true); // XXX
+
return OK;
}
@@ -130,9 +158,12 @@
m_availableSphre.release(); //Force exiting the waiting state
}
+
+
//0 for non-blocking (returns immediately), -1 for infinite blocking
/*virtual*/ int USBSerialStream::write(uint8_t* buf, size_t length, uint32_t timeout/*=-1*/)
{
+ //printBuffer(buf,length,false); // XXX
DBG("Trying to write %d chars", length);
do
{
@@ -160,7 +191,6 @@
}
setupWriteableISR(true);
} while(length);
-
DBG("Write successful");
return OK;
}

Vodafone K3770 3G Modem