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.
Revision 5:f232b826e1f2, committed 2014-12-31
- Comitter:
- Letme
- Date:
- Wed Dec 31 22:23:19 2014 +0000
- Parent:
- 4:9360fdf3a818
- Commit message:
- Fixed some minor bugz and added clearing of stash buffer once whole chunk is printed to L_SERIAL. Also expanded documentation a bit.
Changed in this revision
| logger.cpp | Show annotated file Show diff for this revision Revisions of this file |
| logger.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/logger.cpp Wed Dec 31 22:14:48 2014 +0000
+++ b/logger.cpp Wed Dec 31 22:23:19 2014 +0000
@@ -9,7 +9,10 @@
* @short Logging library provides more standard re-routing of output.
* @details While data logger needs an input to define where it output should go, we
* could also override the output using a global variable, which would be read
- * before the entry into plc switch to override the local output request.
+ * before the entry into plc switch to override the local output request. Function
+ * needs outside buffer definition on which it can stash messages and perform
+ * a string buffer. This are then passed into stash and pop functions when
+ * such logging is assummed.
*
*/
@@ -119,6 +122,8 @@
* Log_stash is meant to stash logs until they are ready to be sent, using log_pop function
* Remember that this function can return also buffer full as result, which means you have to keep
* deciding what you want to do - it just stashes files, but it keeps them in in case of buffer overflow.
+ * Stash buffer is defined outside library and passed in as memoryspace.
+ *
* @param[in] lvl Debug level (ERROR,WARNING,DEBUG)
* @param[in] msg pointer to message
* @param[in] length length of message
@@ -128,7 +133,6 @@
* @retval 1 success
* @retval -ERR linux errno error message - also includes buffer full!
*
- * @warning STASH_BUFFER_LEN sets the size of stash buffer - in case you are lacking space consider making the buffer smaller
*/
int32_t log_stash(uint8_t lvl, char *msg, uint32_t length, char *stash_buffer,size_t stash_buffer_len) {
if((msg == NULL) || (length == 0) || (stash_buffer == NULL) || (stash_buffer_len == 0))
@@ -168,7 +172,10 @@
}
/**
- * Log_pop function sends everything log_stash stashed
+ * Log_pop function sends everything log_stash stashed. Stash buffer is defined outside of function
+ * and pointer to memory space is passed into it. Make sure you have a string buffer on
+ * passed location, as there is still not enough checks against that
+ *
* @param[in] plc Place to where you pop stashed messages
* @param[in] *stash_buffer Place where stashed messages were saved
* @param[in] stash_buffer_len how many characters can be saved on stashed message buffer
@@ -176,6 +183,7 @@
* @retval 1 for success
* @retval 2 for partial printout - did not send everything. You need to recall the function within timer so that you do not flood the serial port. So far it is only on BTSerial.
* @retval -ERR errno.h error message
+ *
*/
int32_t log_pop(uint8_t plc,char *stash_buffer,size_t stash_buffer_len) {
if((stash_buffer == NULL) || (stash_buffer_len == 0))
@@ -190,6 +198,12 @@
case L_SERIAL:
if(logSerial.writeable()) {
logSerial.printf("%s",stash_buffer);
+
+ //clear stash buffer
+ int i;
+ for(i=0;i<stash_buffer_len;++i) {
+ stash_buffer[i]=0;
+ }
} else {
return -EBUSY;
}
@@ -222,11 +236,6 @@
}
- //clear stash buffer
- /* int i;
- for(i=0;i<STASH_BUFFER_LEN;++i) {
- stash_buffer[i]=0;
- }*/
return 1;
}
/**
--- a/logger.h Wed Dec 31 22:14:48 2014 +0000
+++ b/logger.h Wed Dec 31 22:23:19 2014 +0000
@@ -2,6 +2,11 @@
#define _LOGGER_H_
/**
+ * @addtogroup logger_lib
+ * @{
+ */
+
+/**
* Possible outputs of microcontroller
* @todo include also output to LCD display and some other displays
* \def L_SERIAL
@@ -44,5 +49,5 @@
int32_t log_init(uint8_t plc);
int32_t log_stash(uint8_t lvl, char *msg, uint32_t length, char *stash_buffer,size_t stash_buffer_len);
int32_t log_pop(uint8_t plc, char *stash_buffer,size_t stash_buffer_len);
-
+///@}
#endif
\ No newline at end of file