You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/01/12 15:49:22 UTC

[incubator-nuttx-apps] branch master updated: Include the file name to open and the fail error number

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 9211318  Include the file name to open and the fail error number
9211318 is described below

commit 921131895e5395d7e323624458345fad17744141
Author: Alan Carvalho de Assis <ac...@gmail.com>
AuthorDate: Sun Jan 12 12:36:17 2020 -0300

    Include the file name to open and the fail error number
    
    Also fix issues reported by nxstyle
---
 examples/sx127x_demo/sx127x_demo.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/examples/sx127x_demo/sx127x_demo.c b/examples/sx127x_demo/sx127x_demo.c
index 7b1dcdb..a6f5408 100644
--- a/examples/sx127x_demo/sx127x_demo.c
+++ b/examples/sx127x_demo/sx127x_demo.c
@@ -182,7 +182,7 @@ static void parse_args(FAR struct args_s *args, int argc, FAR char **argv)
   int nargs;
   int i_value;
 
-  for (index = 1; index < argc;)
+  for (index = 1; index < argc; )
     {
       ptr = argv[index];
       if (ptr[0] != '-')
@@ -346,22 +346,23 @@ static void print_hex(uint8_t *data, int len)
 {
   int i;
 
-  if(len == 0)
+  if (len == 0)
     {
       printf("empty buffer!\n");
     }
   else
     {
-      for(i = 0 ; i < len ; i += 1)
+      for (i = 0 ; i < len ; i += 1)
         {
           printf("0x%02x ", data[i]);
 
-          if((i+1)%10 == 0)
+          if ((i + 1) % 10 == 0)
             {
               printf("\n");
             }
         }
     }
+
   printf("\n");
 }
 
@@ -447,7 +448,7 @@ int main(int argc, FAR char *argv[])
 
   /* Initialize buffer with data */
 
-  for (i = 0; i < TX_BUFFER_MAX; i+=1)
+  for (i = 0; i < TX_BUFFER_MAX; i += 1)
     {
       buffer[i] = i;
     }
@@ -483,7 +484,8 @@ int main(int argc, FAR char *argv[])
   fd = open(DEV_NAME, O_RDWR);
   if (fd < 0)
     {
-      printf("ERROR: Failed to open device!\n");
+      int errcode = errno;
+      printf("ERROR: Failed to open device %s: %d\n", DEV_NAME, errcode);
       goto errout;
     }
 
@@ -522,7 +524,7 @@ int main(int argc, FAR char *argv[])
 
   clock_gettime(CLOCK_REALTIME, &tstart);
 
-  while(1)
+  while (1)
     {
       switch (args->app_mode)
         {