Integrating the ublox LISA C200 modem
Fork of SprintUSBModemHTTPClientTest by
SprintUSBModem/serial/usb/USBSerialStream.h@21:3f45e53afe4f, 2013-10-08 (annotated)
- Committer:
- sam_grove
- Date:
- Tue Oct 08 00:08:22 2013 +0000
- Revision:
- 21:3f45e53afe4f
- Parent:
- 5:3f93dd1d4cb3
Added http client test. Return from post seems to be a bit wonky but haven't looked closely at this
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 5:3f93dd1d4cb3 | 1 | /* USBSerialStream.h */ |
sam_grove | 5:3f93dd1d4cb3 | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
sam_grove | 5:3f93dd1d4cb3 | 3 | * |
sam_grove | 5:3f93dd1d4cb3 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
sam_grove | 5:3f93dd1d4cb3 | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
sam_grove | 5:3f93dd1d4cb3 | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
sam_grove | 5:3f93dd1d4cb3 | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
sam_grove | 5:3f93dd1d4cb3 | 8 | * furnished to do so, subject to the following conditions: |
sam_grove | 5:3f93dd1d4cb3 | 9 | * |
sam_grove | 5:3f93dd1d4cb3 | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
sam_grove | 5:3f93dd1d4cb3 | 11 | * substantial portions of the Software. |
sam_grove | 5:3f93dd1d4cb3 | 12 | * |
sam_grove | 5:3f93dd1d4cb3 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
sam_grove | 5:3f93dd1d4cb3 | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
sam_grove | 5:3f93dd1d4cb3 | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
sam_grove | 5:3f93dd1d4cb3 | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
sam_grove | 5:3f93dd1d4cb3 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
sam_grove | 5:3f93dd1d4cb3 | 18 | */ |
sam_grove | 5:3f93dd1d4cb3 | 19 | |
sam_grove | 5:3f93dd1d4cb3 | 20 | #ifndef USBSERIALSTREAM_H_ |
sam_grove | 5:3f93dd1d4cb3 | 21 | #define USBSERIALSTREAM_H_ |
sam_grove | 5:3f93dd1d4cb3 | 22 | |
sam_grove | 5:3f93dd1d4cb3 | 23 | |
sam_grove | 5:3f93dd1d4cb3 | 24 | #include "core/fwk.h" |
sam_grove | 5:3f93dd1d4cb3 | 25 | |
sam_grove | 5:3f93dd1d4cb3 | 26 | #include "USB3GModule/IUSBHostSerial.h" |
sam_grove | 5:3f93dd1d4cb3 | 27 | #include "USB3GModule/IUSBHostSerialListener.h" |
sam_grove | 5:3f93dd1d4cb3 | 28 | |
sam_grove | 5:3f93dd1d4cb3 | 29 | #include "rtos.h" |
sam_grove | 5:3f93dd1d4cb3 | 30 | #include "core/MtxCircBuffer.h" |
sam_grove | 5:3f93dd1d4cb3 | 31 | |
sam_grove | 5:3f93dd1d4cb3 | 32 | /* Input Serial Stream for USB virtual serial ports interfaces |
sam_grove | 5:3f93dd1d4cb3 | 33 | This class is not thread-safe, except for the *Abort() methods that can be called by any thread/ISR |
sam_grove | 5:3f93dd1d4cb3 | 34 | */ |
sam_grove | 5:3f93dd1d4cb3 | 35 | #define CIRCBUF_SIZE 127 |
sam_grove | 5:3f93dd1d4cb3 | 36 | class USBSerialStream : public IOStream, IUSBHostSerialListener |
sam_grove | 5:3f93dd1d4cb3 | 37 | { |
sam_grove | 5:3f93dd1d4cb3 | 38 | public: |
sam_grove | 5:3f93dd1d4cb3 | 39 | USBSerialStream(IUSBHostSerial& serial); |
sam_grove | 5:3f93dd1d4cb3 | 40 | /*virtual*/ ~USBSerialStream(); |
sam_grove | 5:3f93dd1d4cb3 | 41 | |
sam_grove | 5:3f93dd1d4cb3 | 42 | //0 for non-blocking (returns immediately), osWaitForever for infinite blocking |
sam_grove | 5:3f93dd1d4cb3 | 43 | virtual int read(uint8_t* buf, size_t* pLength, size_t maxLength, uint32_t timeout=osWaitForever); |
sam_grove | 5:3f93dd1d4cb3 | 44 | virtual size_t available(); |
sam_grove | 5:3f93dd1d4cb3 | 45 | virtual int waitAvailable(uint32_t timeout=osWaitForever); //Wait for data to be available |
sam_grove | 5:3f93dd1d4cb3 | 46 | virtual int abortRead(); //Abort current reading (or waiting) operation |
sam_grove | 5:3f93dd1d4cb3 | 47 | |
sam_grove | 5:3f93dd1d4cb3 | 48 | |
sam_grove | 5:3f93dd1d4cb3 | 49 | //0 for non-blocking (returns immediately), osWaitForever for infinite blocking |
sam_grove | 5:3f93dd1d4cb3 | 50 | virtual int write(uint8_t* buf, size_t length, uint32_t timeout=osWaitForever); |
sam_grove | 5:3f93dd1d4cb3 | 51 | virtual size_t space(); |
sam_grove | 5:3f93dd1d4cb3 | 52 | virtual int waitSpace(uint32_t timeout=osWaitForever); //Wait for space to be available |
sam_grove | 5:3f93dd1d4cb3 | 53 | virtual int abortWrite(); //Abort current writing (or waiting) operation |
sam_grove | 5:3f93dd1d4cb3 | 54 | |
sam_grove | 5:3f93dd1d4cb3 | 55 | private: |
sam_grove | 5:3f93dd1d4cb3 | 56 | IUSBHostSerial& m_serial; |
sam_grove | 5:3f93dd1d4cb3 | 57 | volatile bool m_serialTxFifoEmpty; |
sam_grove | 5:3f93dd1d4cb3 | 58 | |
sam_grove | 5:3f93dd1d4cb3 | 59 | void setupReadableISR(bool en); |
sam_grove | 5:3f93dd1d4cb3 | 60 | virtual void readable(); //Callback from m_serial when new data is available |
sam_grove | 5:3f93dd1d4cb3 | 61 | |
sam_grove | 5:3f93dd1d4cb3 | 62 | Semaphore m_availableSphre; //Used for signalling |
sam_grove | 5:3f93dd1d4cb3 | 63 | |
sam_grove | 5:3f93dd1d4cb3 | 64 | void setupWriteableISR(bool en); |
sam_grove | 5:3f93dd1d4cb3 | 65 | virtual void writeable(); //Callback from m_serial when new space is available |
sam_grove | 5:3f93dd1d4cb3 | 66 | |
sam_grove | 5:3f93dd1d4cb3 | 67 | Semaphore m_spaceSphre; //Used for signalling |
sam_grove | 5:3f93dd1d4cb3 | 68 | |
sam_grove | 5:3f93dd1d4cb3 | 69 | MtxCircBuffer<uint8_t, CIRCBUF_SIZE + 1> m_inBuf; |
sam_grove | 5:3f93dd1d4cb3 | 70 | MtxCircBuffer<uint8_t, CIRCBUF_SIZE + 1> m_outBuf; |
sam_grove | 5:3f93dd1d4cb3 | 71 | }; |
sam_grove | 5:3f93dd1d4cb3 | 72 | |
sam_grove | 5:3f93dd1d4cb3 | 73 | #endif /* USBSERIALSTREAM_H_ */ |