michallenc commented on code in PR #3170:
URL: https://github.com/apache/nuttx-apps/pull/3170#discussion_r2312596761


##########
examples/shv-nxboot-updater/update-script/gui.py:
##########
@@ -0,0 +1,221 @@
+#!/usr/bin/env python3

Review Comment:
   add `requirements.txt` with packages needed to run those scripts



##########
examples/shv-nxboot-updater/update-script/shvconfirm.py:
##########
@@ -0,0 +1,31 @@
+############################################################################
+# apps/examples/shv-nxboot-updater/update-script/shvconfirm.py
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+from shv import RpcUrl, ValueClient

Review Comment:
   These imports won't work with `pyshv >= 0.10.0`. I don't think we need 
backwards compatibility here, just change imports and ensure `pyshv >= 0.10.0` 
in `requirements.txt `



##########
examples/shv-nxboot-updater/update-script/shvflasher.py:
##########
@@ -0,0 +1,80 @@
+############################################################################
+# apps/examples/shv-nxboot-updater/update-script/shvflasher.py
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+import asyncio
+import io
+import zlib
+
+from shv import RpcUrl, SHVBytes, ValueClient

Review Comment:
   ditto



##########
examples/shv-nxboot-updater/shv_nxboot_updater.c:
##########
@@ -0,0 +1,424 @@
+/****************************************************************************
+ * apps/examples/shv-nxboot-updater/shv_nxboot_updater.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <shv/tree/shv_tree.h>
+#include <shv/tree/shv_file_node.h>
+#include <shv/tree/shv_connection.h>
+#include <shv/tree/shv_methods.h>
+#include <shv/tree/shv_clayer_posix.h>
+#include <shv/tree/shv_dotdevice_node.h>
+
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <semaphore.h>
+
+#ifdef __NuttX__
+#include <nxboot.h>
+#include <nuttx/mtd/mtd.h>
+#include <sys/boardctl.h>
+#endif
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int shv_nxboot_opener(shv_file_node_t *item);
+static int shv_root_device_type(shv_con_ctx_t * shv_ctx, shv_node_t *item,
+                                int rid);
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_vminor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_name(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_dotapp_ping(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_fwstable_confirm(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                int rid);
+static void quit_handler(int signum);
+static void print_help(char *name);
+
+static shv_node_t *shv_tree_create(void);
+static void attention_cb(shv_con_ctx_t *shv_ctx,
+                         enum shv_attention_reason r);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* An execution barrier */
+
+static sem_t running;
+
+/* ------------------------- ROOT METHODS --------------------------------- */
+
+static const shv_method_des_t shv_dev_root_dmap_item_device_type =
+{
+  .name = "deviceType",
+  .method = shv_root_device_type

Review Comment:
   What is the purpose of this method?



##########
examples/shv-nxboot-updater/shv_nxboot_updater.c:
##########
@@ -0,0 +1,424 @@
+/****************************************************************************
+ * apps/examples/shv-nxboot-updater/shv_nxboot_updater.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <shv/tree/shv_tree.h>
+#include <shv/tree/shv_file_node.h>
+#include <shv/tree/shv_connection.h>
+#include <shv/tree/shv_methods.h>
+#include <shv/tree/shv_clayer_posix.h>
+#include <shv/tree/shv_dotdevice_node.h>
+
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <semaphore.h>
+
+#ifdef __NuttX__
+#include <nxboot.h>
+#include <nuttx/mtd/mtd.h>
+#include <sys/boardctl.h>
+#endif
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int shv_nxboot_opener(shv_file_node_t *item);
+static int shv_root_device_type(shv_con_ctx_t * shv_ctx, shv_node_t *item,
+                                int rid);
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_vminor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_name(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_dotapp_ping(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_fwstable_confirm(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                int rid);
+static void quit_handler(int signum);
+static void print_help(char *name);
+
+static shv_node_t *shv_tree_create(void);
+static void attention_cb(shv_con_ctx_t *shv_ctx,
+                         enum shv_attention_reason r);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* An execution barrier */
+
+static sem_t running;
+
+/* ------------------------- ROOT METHODS --------------------------------- */
+
+static const shv_method_des_t shv_dev_root_dmap_item_device_type =
+{
+  .name = "deviceType",
+  .method = shv_root_device_type
+};
+
+static const shv_method_des_t * const shv_dev_root_dmap_items[] =
+{
+  &shv_dev_root_dmap_item_device_type,
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+};
+
+static const shv_dmap_t shv_dev_root_dmap =
+  SHV_CREATE_NODE_DMAP(root, shv_dev_root_dmap_items);
+
+/* ------------------------- .app METHODS ---------------------------- */
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vmajor =
+{
+  .name = "shvVersionMajor",
+  .method = shv_dotapp_vmajor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vminor =
+{
+  .name = "shvVersionMinor",
+  .method = shv_dotapp_vminor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_name =
+{
+  .name = "name",
+  .method = shv_dotapp_name
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_ping =
+{
+  .name = "ping",
+  .method = shv_dotapp_ping
+};
+
+static const shv_method_des_t * const shv_dev_dotapp_dmap_items[] =
+{
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+  &shv_dev_dotapp_dmap_item_name,
+  &shv_dev_dotapp_dmap_item_ping,
+  &shv_dev_dotapp_dmap_item_vmajor,
+  &shv_dev_dotapp_dmap_item_vminor,
+};
+
+static const shv_dmap_t shv_dev_dotapp_dmap =
+  SHV_CREATE_NODE_DMAP(dotapp, shv_dev_dotapp_dmap_items);
+
+/* ------------------------- fwstable METHODS ---------------------------- */
+
+static const shv_method_des_t shv_dev_fwstable_dmap_item_confirm =
+{
+  .name = "confirm",
+  .method = shv_fwstable_confirm
+};
+
+static const shv_method_des_t * const shv_dev_fwstable_dmap_items[] =
+{
+  &shv_dev_fwstable_dmap_item_confirm,
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls
+};
+
+static const shv_dmap_t shv_dev_fwstable_dmap =
+  SHV_CREATE_NODE_DMAP(dotdevice, shv_dev_fwstable_dmap_items);
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid)
+{
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  shv_send_int(shv_ctx, rid, 1);

Review Comment:
   This is SHV version major, therefore it should be `3` as we comply with 
version `3.0`



##########
examples/shv-nxboot-updater/shv_nxboot_updater.c:
##########
@@ -0,0 +1,424 @@
+/****************************************************************************
+ * apps/examples/shv-nxboot-updater/shv_nxboot_updater.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <shv/tree/shv_tree.h>
+#include <shv/tree/shv_file_node.h>
+#include <shv/tree/shv_connection.h>
+#include <shv/tree/shv_methods.h>
+#include <shv/tree/shv_clayer_posix.h>
+#include <shv/tree/shv_dotdevice_node.h>
+
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <semaphore.h>
+
+#ifdef __NuttX__

Review Comment:
   This is always true in NuttX apps.



##########
examples/shv-nxboot-updater/update-script/gui.py:
##########
@@ -0,0 +1,221 @@
+#!/usr/bin/env python3
+
+############################################################################
+# apps/examples/shv-nxboot-updater/update-script/gui.py
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+import argparse
+import asyncio
+import logging
+import sys
+from typing import Any
+
+from PyQt6.QtCore import Qt, QThread
+from PyQt6.QtWidgets import (
+    QApplication,
+    QComboBox,
+    QDialog,
+    QGridLayout,
+    QLabel,
+    QLineEdit,
+    QProgressBar,
+    QPushButton,
+)
+
+from shvconfirm import shv_confirm
+from shvflasher import shv_flasher
+
+log_levels = (
+    logging.DEBUG,
+    logging.INFO,
+    logging.WARNING,
+    logging.ERROR,
+    logging.CRITICAL,
+)
+
+PROGRESS_STYLE = """
+QProgressBar{
+    border: 2px solid grey;
+    border-radius: 5px;
+    text-align: center
+}
+
+QProgressBar::chunk {
+    background-color: green;
+}
+"""
+
+
+def parse_args() -> argparse.Namespace:
+    """Parse passed arguments and return result."""
+    parser = argparse.ArgumentParser(
+        description="GUI application for NuttX firmware flash over SHV"
+    )
+    parser.add_argument(
+        "-v",
+        action="count",
+        default=0,
+        help="Increase verbosity level of logging",
+    )
+    parser.add_argument(
+        "-q",
+        action="count",
+        default=0,
+        help="Decrease verbosity level of logging",
+    )
+    parser.add_argument(
+        '-i', '--image',
+        dest='image',
+        type=str,
+        default='update.img',
+        help='Image path'
+    )
+    parser.add_argument(
+        '-m', '--mount',
+        dest='target_mount',
+        type=str,
+        default='test/samocon-1',

Review Comment:
   Change to something nuttx generic



##########
examples/shv-nxboot-updater/shv_nxboot_updater.c:
##########
@@ -0,0 +1,424 @@
+/****************************************************************************
+ * apps/examples/shv-nxboot-updater/shv_nxboot_updater.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <shv/tree/shv_tree.h>
+#include <shv/tree/shv_file_node.h>
+#include <shv/tree/shv_connection.h>
+#include <shv/tree/shv_methods.h>
+#include <shv/tree/shv_clayer_posix.h>
+#include <shv/tree/shv_dotdevice_node.h>
+
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <semaphore.h>
+
+#ifdef __NuttX__
+#include <nxboot.h>
+#include <nuttx/mtd/mtd.h>
+#include <sys/boardctl.h>
+#endif
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int shv_nxboot_opener(shv_file_node_t *item);
+static int shv_root_device_type(shv_con_ctx_t * shv_ctx, shv_node_t *item,
+                                int rid);
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_vminor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_name(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_dotapp_ping(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_fwstable_confirm(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                int rid);
+static void quit_handler(int signum);
+static void print_help(char *name);
+
+static shv_node_t *shv_tree_create(void);
+static void attention_cb(shv_con_ctx_t *shv_ctx,
+                         enum shv_attention_reason r);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* An execution barrier */
+
+static sem_t running;
+
+/* ------------------------- ROOT METHODS --------------------------------- */
+
+static const shv_method_des_t shv_dev_root_dmap_item_device_type =
+{
+  .name = "deviceType",
+  .method = shv_root_device_type
+};
+
+static const shv_method_des_t * const shv_dev_root_dmap_items[] =
+{
+  &shv_dev_root_dmap_item_device_type,
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+};
+
+static const shv_dmap_t shv_dev_root_dmap =
+  SHV_CREATE_NODE_DMAP(root, shv_dev_root_dmap_items);
+
+/* ------------------------- .app METHODS ---------------------------- */
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vmajor =
+{
+  .name = "shvVersionMajor",
+  .method = shv_dotapp_vmajor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vminor =
+{
+  .name = "shvVersionMinor",
+  .method = shv_dotapp_vminor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_name =
+{
+  .name = "name",
+  .method = shv_dotapp_name
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_ping =
+{
+  .name = "ping",
+  .method = shv_dotapp_ping
+};
+
+static const shv_method_des_t * const shv_dev_dotapp_dmap_items[] =
+{
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+  &shv_dev_dotapp_dmap_item_name,
+  &shv_dev_dotapp_dmap_item_ping,
+  &shv_dev_dotapp_dmap_item_vmajor,
+  &shv_dev_dotapp_dmap_item_vminor,
+};
+
+static const shv_dmap_t shv_dev_dotapp_dmap =
+  SHV_CREATE_NODE_DMAP(dotapp, shv_dev_dotapp_dmap_items);
+
+/* ------------------------- fwstable METHODS ---------------------------- */
+
+static const shv_method_des_t shv_dev_fwstable_dmap_item_confirm =
+{
+  .name = "confirm",
+  .method = shv_fwstable_confirm
+};
+
+static const shv_method_des_t * const shv_dev_fwstable_dmap_items[] =

Review Comment:
   there should also be `fwStable:get` method that returns `true` or `false` 
based on fw status.



##########
examples/shv-test/shv_test.c:
##########
@@ -0,0 +1,510 @@
+/****************************************************************************
+ * apps/examples/shv-test/shv_test.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <shv/tree/shv_tree.h>
+#include <shv/tree/shv_file_node.h>
+#include <shv/tree/shv_connection.h>
+#include <shv/tree/shv_methods.h>
+#include <shv/tree/shv_clayer_posix.h>
+#include <shv/tree/shv_dotdevice_node.h>
+
+#include <nuttx/config.h>
+#include <stdio.h>
+#include <signal.h>
+#include <semaphore.h>
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int shv_root_device_type(shv_con_ctx_t * shv_ctx, shv_node_t *item,
+                                int rid);
+
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_vminor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_name(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_dotapp_ping(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+
+static int shv_nuttxtesting_set(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                int rid);
+static int shv_nuttxtesting_get(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                 int rid);
+static int shv_nuttxtesting_art(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                 int rid);
+
+static void quit_handler(int signum);
+static void print_help(char *name);
+
+static shv_node_t *shv_tree_create_dynamically(int mode);
+static void attention_cb(shv_con_ctx_t *shv_ctx,
+                         enum shv_attention_reason r);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* An execution barrier */
+
+static sem_t running;
+
+/* Testing variable */
+
+static int g_testing_val;
+
+/* ------------------------- ROOT METHODS --------------------------------- */
+
+static const shv_method_des_t shv_dev_root_dmap_item_device_type =
+{
+  .name = "deviceType",
+  .method = shv_root_device_type
+};
+
+static const shv_method_des_t * const shv_dev_root_dmap_items[] =
+{
+  &shv_dev_root_dmap_item_device_type,
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+};
+
+static const shv_dmap_t shv_dev_root_dmap =
+  SHV_CREATE_NODE_DMAP(root, shv_dev_root_dmap_items);
+
+/* ------------------------- .app METHODS ---------------------------- */
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vmajor =
+{
+  .name = "shvVersionMajor",
+  .method = shv_dotapp_vmajor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vminor =
+{
+  .name = "shvVersionMinor",
+  .method = shv_dotapp_vminor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_name =
+{
+  .name = "name",
+  .method = shv_dotapp_name
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_ping =
+{
+  .name = "ping",
+  .method = shv_dotapp_ping
+};
+
+static const shv_method_des_t * const shv_dev_dotapp_dmap_items[] =
+{
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+  &shv_dev_dotapp_dmap_item_name,
+  &shv_dev_dotapp_dmap_item_ping,
+  &shv_dev_dotapp_dmap_item_vmajor,
+  &shv_dev_dotapp_dmap_item_vminor,
+};
+
+static const shv_dmap_t shv_dev_dotapp_dmap =
+  SHV_CREATE_NODE_DMAP(dotapp, shv_dev_dotapp_dmap_items);
+
+/* ----------------------- nuttxtesting METHODS -------------------------- */
+
+static const shv_method_des_t shv_dev_nuttxtesting_dmap_item_set =
+{
+  .name = "setTestingVal",
+  .method = shv_nuttxtesting_set
+};
+
+static const shv_method_des_t shv_dev_nuttxtesting_dmap_item_get =
+{
+  .name = "getTestingVal",
+  .method = shv_nuttxtesting_get
+};
+
+static const shv_method_des_t shv_dev_nuttxtesting_dmap_item_art =
+{
+  .name = "asciiArt",
+  .method = shv_nuttxtesting_art
+};
+
+static const shv_method_des_t *const shv_dev_nuttxtesting_dmap_items[] =
+{
+  &shv_dev_nuttxtesting_dmap_item_art,
+  &shv_dmap_item_dir,
+  &shv_dev_nuttxtesting_dmap_item_get,
+  &shv_dmap_item_ls,
+  &shv_dev_nuttxtesting_dmap_item_set
+};
+
+static const shv_dmap_t shv_dev_nuttxtesting_dmap =
+  SHV_CREATE_NODE_DMAP(nuttxtesting, shv_dev_nuttxtesting_dmap_items);
+
+/* ------------------- Static const tree root creation ------------------- */
+
+/* First, define all static nodes */
+
+static const shv_dotdevice_node_t shv_static_node_dotdevice =
+{
+  .shv_node =
+  {
+    .name = ".device",
+    .dir = UL_CAST_UNQ1(shv_dmap_t *, &shv_dotdevice_dmap),
+    .children =
+    {
+      .mode = (SHV_NLIST_MODE_GSA | SHV_NLIST_MODE_STATIC)
+    }
+  },
+  .devops =
+  {
+    .reset  = shv_dotdevice_node_posix_reset,
+    .uptime = shv_dotdevice_node_posix_uptime
+  },
+  .name = "SHV Compatible Device",
+  .serial_number = "0xDEADBEEF",
+  .version = "0.1.0"
+};
+
+static const shv_node_t shv_static_node_dotapp =
+{
+  .name = ".app",
+  .dir = UL_CAST_UNQ1(shv_dmap_t *, &shv_dev_dotapp_dmap),
+  .children =
+  {
+    .mode = (SHV_NLIST_MODE_GSA | SHV_NLIST_MODE_STATIC)
+  }
+};
+
+static const shv_node_t shv_static_node_nuttxtesting =
+{
+  .name = "nuttxTesting",
+  .dir = UL_CAST_UNQ1(shv_dmap_t *, &shv_dev_nuttxtesting_dmap),
+  .children =
+  {
+    .mode = (SHV_NLIST_MODE_GSA | SHV_NLIST_MODE_STATIC)
+  }
+};
+
+/* Now, define tree root's children */
+
+const shv_node_t *const shv_static_tree_root_items[] =
+{
+  &shv_static_node_dotapp,
+  &shv_static_node_dotdevice.shv_node,
+  &shv_static_node_nuttxtesting
+};
+
+/* Construct the root. Yes, it's a bit cumbersome,
+ * but an automated code generator should have no problem with this!
+ */
+
+const shv_node_t shv_static_tree_root =
+{
+  .dir = UL_CAST_UNQ1(shv_dmap_t *, &shv_dev_root_dmap),
+  .children =
+  {
+    .mode = (SHV_NLIST_MODE_GSA | SHV_NLIST_MODE_STATIC),
+    .list =
+    {
+      .gsa =
+      {
+        .root =
+        {
+          .items = (void **)shv_static_tree_root_items,
+          .count = sizeof(shv_static_tree_root_items) /
+                   sizeof(shv_static_tree_root_items[0]),
+          .alloc_count = 0,
+        }
+      }
+    }
+  }
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid)
+{
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  shv_send_int(shv_ctx, rid, 1);

Review Comment:
   ```suggestion
     shv_send_int(shv_ctx, rid, 3);
   ```



##########
examples/shv-nxboot-updater/update-script/gui.py:
##########
@@ -0,0 +1,221 @@
+#!/usr/bin/env python3
+
+############################################################################
+# apps/examples/shv-nxboot-updater/update-script/gui.py
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+import argparse
+import asyncio
+import logging
+import sys
+from typing import Any
+
+from PyQt6.QtCore import Qt, QThread
+from PyQt6.QtWidgets import (
+    QApplication,
+    QComboBox,
+    QDialog,
+    QGridLayout,
+    QLabel,
+    QLineEdit,
+    QProgressBar,
+    QPushButton,
+)
+
+from shvconfirm import shv_confirm
+from shvflasher import shv_flasher
+
+log_levels = (
+    logging.DEBUG,
+    logging.INFO,
+    logging.WARNING,
+    logging.ERROR,
+    logging.CRITICAL,
+)
+
+PROGRESS_STYLE = """
+QProgressBar{
+    border: 2px solid grey;
+    border-radius: 5px;
+    text-align: center
+}
+
+QProgressBar::chunk {
+    background-color: green;
+}
+"""
+
+
+def parse_args() -> argparse.Namespace:
+    """Parse passed arguments and return result."""
+    parser = argparse.ArgumentParser(
+        description="GUI application for NuttX firmware flash over SHV"
+    )
+    parser.add_argument(
+        "-v",
+        action="count",
+        default=0,
+        help="Increase verbosity level of logging",
+    )
+    parser.add_argument(
+        "-q",
+        action="count",
+        default=0,
+        help="Decrease verbosity level of logging",
+    )
+    parser.add_argument(
+        '-i', '--image',
+        dest='image',
+        type=str,
+        default='update.img',

Review Comment:
   ```suggestion
           default='nuttx.nximg',
   ```



##########
examples/shv-nxboot-updater/shv_nxboot_updater.c:
##########
@@ -0,0 +1,424 @@
+/****************************************************************************
+ * apps/examples/shv-nxboot-updater/shv_nxboot_updater.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <shv/tree/shv_tree.h>
+#include <shv/tree/shv_file_node.h>
+#include <shv/tree/shv_connection.h>
+#include <shv/tree/shv_methods.h>
+#include <shv/tree/shv_clayer_posix.h>
+#include <shv/tree/shv_dotdevice_node.h>
+
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <semaphore.h>
+
+#ifdef __NuttX__
+#include <nxboot.h>
+#include <nuttx/mtd/mtd.h>
+#include <sys/boardctl.h>
+#endif
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int shv_nxboot_opener(shv_file_node_t *item);
+static int shv_root_device_type(shv_con_ctx_t * shv_ctx, shv_node_t *item,
+                                int rid);
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_vminor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid);
+static int shv_dotapp_name(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_dotapp_ping(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid);
+static int shv_fwstable_confirm(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                int rid);
+static void quit_handler(int signum);
+static void print_help(char *name);
+
+static shv_node_t *shv_tree_create(void);
+static void attention_cb(shv_con_ctx_t *shv_ctx,
+                         enum shv_attention_reason r);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* An execution barrier */
+
+static sem_t running;
+
+/* ------------------------- ROOT METHODS --------------------------------- */
+
+static const shv_method_des_t shv_dev_root_dmap_item_device_type =
+{
+  .name = "deviceType",
+  .method = shv_root_device_type
+};
+
+static const shv_method_des_t * const shv_dev_root_dmap_items[] =
+{
+  &shv_dev_root_dmap_item_device_type,
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+};
+
+static const shv_dmap_t shv_dev_root_dmap =
+  SHV_CREATE_NODE_DMAP(root, shv_dev_root_dmap_items);
+
+/* ------------------------- .app METHODS ---------------------------- */
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vmajor =
+{
+  .name = "shvVersionMajor",
+  .method = shv_dotapp_vmajor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_vminor =
+{
+  .name = "shvVersionMinor",
+  .method = shv_dotapp_vminor
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_name =
+{
+  .name = "name",
+  .method = shv_dotapp_name
+};
+
+static const shv_method_des_t shv_dev_dotapp_dmap_item_ping =
+{
+  .name = "ping",
+  .method = shv_dotapp_ping
+};
+
+static const shv_method_des_t * const shv_dev_dotapp_dmap_items[] =
+{
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls,
+  &shv_dev_dotapp_dmap_item_name,
+  &shv_dev_dotapp_dmap_item_ping,
+  &shv_dev_dotapp_dmap_item_vmajor,
+  &shv_dev_dotapp_dmap_item_vminor,
+};
+
+static const shv_dmap_t shv_dev_dotapp_dmap =
+  SHV_CREATE_NODE_DMAP(dotapp, shv_dev_dotapp_dmap_items);
+
+/* ------------------------- fwstable METHODS ---------------------------- */
+
+static const shv_method_des_t shv_dev_fwstable_dmap_item_confirm =
+{
+  .name = "confirm",
+  .method = shv_fwstable_confirm
+};
+
+static const shv_method_des_t * const shv_dev_fwstable_dmap_items[] =
+{
+  &shv_dev_fwstable_dmap_item_confirm,
+  &shv_dmap_item_dir,
+  &shv_dmap_item_ls
+};
+
+static const shv_dmap_t shv_dev_fwstable_dmap =
+  SHV_CREATE_NODE_DMAP(dotdevice, shv_dev_fwstable_dmap_items);
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static int shv_dotapp_vmajor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid)
+{
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  shv_send_int(shv_ctx, rid, 1);
+  return 0;
+}
+
+static int shv_dotapp_vminor(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                             int rid)
+{
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  shv_send_int(shv_ctx, rid, 0);
+  return 0;
+}
+
+static int shv_dotapp_name(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid)
+{
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  shv_send_str(shv_ctx, rid, "SHV Firmware Updater");
+  return 0;
+}
+
+static int shv_dotapp_ping(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                           int rid)
+{
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  shv_send_empty_response(shv_ctx, rid);
+  return 0;
+}
+
+static int shv_root_device_type(shv_con_ctx_t * shv_ctx, shv_node_t *item,
+                                int rid)
+{
+  const char *str = "SHV4LIBS Testing";
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  shv_send_str(shv_ctx, rid, str);
+  return 0;
+}
+
+static int shv_fwstable_confirm(shv_con_ctx_t *shv_ctx, shv_node_t *item,
+                                int rid)
+{
+  shv_unpack_data(&shv_ctx->unpack_ctx, 0, 0);
+  nxboot_confirm();
+  shv_send_int(shv_ctx, rid, 0);

Review Comment:
   ```suggestion
     shv_send_empty_response(shv_ctx, rid);
   ```



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

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


Reply via email to