You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/05/31 13:47:17 UTC

[GitHub] [incubator-nuttx] Donny9 commented on a change in pull request #3808: Ramlog: recover last crash log from ram buffer.

Donny9 commented on a change in pull request #3808:
URL: https://github.com/apache/incubator-nuttx/pull/3808#discussion_r642501719



##########
File path: drivers/syslog/ramlog.c
##########
@@ -639,6 +643,60 @@ int ramlog_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
   return ret;
 }
 
+/****************************************************************************
+ * Name: ramlog_initbuf
+ *
+ * Description:
+ *  Initialize g_sysdev based on the current system ramlog buffer.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_RAMLOG_SYSLOG
+static void ramlog_initbuf(void)
+{
+  FAR struct ramlog_dev_s *priv = &g_sysdev;
+  char prev, cur;
+  size_t i;
+
+  if (priv->rl_head != CONFIG_RAMLOG_BUFSIZE ||
+      priv->rl_tail != CONFIG_RAMLOG_BUFSIZE)
+    {
+      return;
+    }
+
+  prev = priv->rl_buffer[priv->rl_bufsize - 1];
+
+  for (i = 0; i < priv->rl_bufsize; i++)
+    {
+      cur = priv->rl_buffer[i];
+
+      if (!isascii(cur))
+        {
+          goto out;
+        }
+
+      if (prev && !cur)
+        {
+          priv->rl_head = i;
+        }
+
+      if (!prev && cur)
+        {
+          priv->rl_tail = i;
+        }
+
+      prev = cur;
+    }
+
+out:
+  if (i != priv->rl_bufsize)
+    {
+      priv->rl_head = priv->rl_tail = 0;

Review comment:
       Done. Thank you.

##########
File path: drivers/syslog/ramlog.c
##########
@@ -639,6 +643,60 @@ int ramlog_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup)
   return ret;
 }
 
+/****************************************************************************
+ * Name: ramlog_initbuf
+ *
+ * Description:
+ *  Initialize g_sysdev based on the current system ramlog buffer.

Review comment:
       Done. Thank you.

##########
File path: drivers/syslog/Kconfig
##########
@@ -34,6 +34,14 @@ config RAMLOG
 		details as needed to support logging.
 
 if RAMLOG
+config RAMLOG_BUFFER_SECTION
+	string "The section where ramlog buffer is located"
+	default ".bss"
+	depends on RAMLOG_SYSLOG
+	---help---
+		The section where ramlog buffer is located, this section cannot
+		be initialized each time when the system boot.

Review comment:
       Done. Thank you.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org