2121
2222#if  DEVICE_SERIAL || defined(DOXYGEN_ONLY)
2323
24+ #include  < cstdarg> 
25+ 
2426#include  " drivers/SerialBase.h" 
2527#include  " platform/FileHandle.h" 
2628#include  " platform/mbed_toolchain.h" 
2729#include  " platform/NonCopyable.h" 
28- #include  < cstdarg> 
30+ #include  " platform/PlatformMutex.h" 
31+ 
2932
3033namespace  mbed  {
3134
@@ -64,36 +67,28 @@ class UnbufferedSerial:
6467
6568    /* * Write the contents of a buffer to a file
6669     * 
67-      *  Follows POSIX semantics: 
68-      * 
69-      * * if blocking, block until all data is written 
70-      * * if no data can be written, and non-blocking set, return -EAGAIN 
71-      * * if some data can be written, and non-blocking set, write partial 
70+      * Blocks until all data is written 
7271     * 
7372     *  @param buffer   The buffer to write from 
74-      *  @param length    The number of bytes to write 
75-      *  @return         The number of bytes written, negative error on failure  
73+      *  @param size      The number of bytes to write 
74+      *  @return         The number of bytes written 
7675     */  
7776    virtual  ssize_t  write (const  void  *buffer, size_t  size);
7877
7978    /* * Read the contents of a file into a buffer
8079     * 
81-      *  Follows POSIX semantics: 
82-      * 
83-      *  * if no data is available, and non-blocking set return -EAGAIN 
84-      *  * if no data is available, and blocking set, wait until data is available 
85-      *  * If any data is available, call returns immediately 
80+      *  Blocks and reads exactly one character 
8681     * 
8782     *  @param buffer   The buffer to read in to 
88-      *  @param length    The number of bytes to read 
89-      *  @return         The number of bytes read, 0 at end of file, negative error on failure  
83+      *  @param size      The number of bytes to read 
84+      *  @return         The number of bytes read 
9085     */  
9186    virtual  ssize_t  read (void  *buffer, size_t  size);
9287
9388    /* * Move the file position to a given offset from from a given location
9489     * 
95-      * Not valid for a device type FileHandle like UARTSerial . 
96-      * In case of UARTSerial , returns ESPIPE 
90+      * Not valid for a device type FileHandle like UnbufferedSerial . 
91+      * In case of UnbufferedSerial , returns ESPIPE 
9792     * 
9893     *  @param offset   The offset from whence to move to 
9994     *  @param whence   The start of where to seek 
@@ -136,12 +131,17 @@ class UnbufferedSerial:
136131        return  0 ;
137132    }
138133
139-     /* *
140-      * Equivalent to POSIX poll(). Derived from FileHandle. 
141-      * Provides a mechanism to multiplex input/output over a set of file 
142-      * handles. 
134+ 
135+     /* * Check for poll event flags
136+      * Check the events listed in events to see if data can be read or written 
137+      * without blocking. 
138+      * Call is nonblocking - returns state of events. 
139+      * 
140+      * @param events        bitmask of poll events we're interested in - POLLIN/POLLOUT etc. 
141+      * 
142+      * @returns             bitmask of poll events that have occurred. 
143143     */  
144-     virtual  short  poll (short  events)  const ;
144+     virtual  short  poll (short  events);
145145
146146#if  !(DOXYGEN_ONLY)
147147protected: 
@@ -152,6 +152,17 @@ class UnbufferedSerial:
152152    /*  Release exclusive access to this serial port
153153     */  
154154    virtual  void  unlock (void );
155+ 
156+ private: 
157+ 
158+     /* * Acquire mutex */ 
159+     virtual  void  api_lock (void );
160+ 
161+     /* * Release mutex */ 
162+     virtual  void  api_unlock (void );
163+ 
164+ 
165+     PlatformMutex _mutex;
155166#endif  //  !(DOXYGEN_ONLY)
156167};
157168
0 commit comments