<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Another option (quite simple) is if peripherals cannot shutdown immediately, they register their intent to shutdown with ovms_boot.cpp. When done and ready to shutdown they tell ovms_boot that. We keep a counter/list. When zero, we shutdown.</div><div><br></div><div>That is quite elegant. And the fastest possible. We can also have final timeout that if the counter doesn’t hit zero within a timeout, we shutdown anyway.</div><div><br>On 30 Apr 2018, at 3:47 PM, Michael Balzer <<a href="mailto:dexter@expeedo.de">dexter@expeedo.de</a>> wrote:<br><br></div><blockquote type="cite"><div>
  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  
  
    How about:<br>
    <ul>
      <li> init the SD unmounting on the ShuttingDown event, so there's
        plenty of time</li>
      <li>to avoid blocking the "system.shuttingdown" event for
        downstream listeners, fire a separate "sd.shuttingdown" event
        for this and do the synchronous "sd.unmount.prep" in that
        event's listener<br>
      </li>
    </ul>
    If the SD unmounting does not finish within 20 seconds, bad luck --
    you probably have to do a hard shutdown anyway in that case.<br>
    <br>
    Regards,<br>
    Michael<br>
    <br>
    <br>
    <div class="moz-cite-prefix">Am 30.04.2018 um 09:25 schrieb Mark
      Webb-Johnson:<br>
    </div>
    <blockquote type="cite" cite="mid:DFD6A6A1-42D4-4BC5-A899-582D4B0A8FD1@webb-johnson.net">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      Not sure how we can do this, in a generic way, without a delay.
      Let’s look at the “ShutDown” event:
      <div class=""><br class="">
      </div>
      <div class="">
        <ul class="MailOutline">
          <li class="">The “module reset” goes through the first part
            (ShuttingDown), then sends the ShutDown event. We can use a
            ‘done’ callback to know when that event has been delivered.</li>
          <li class="">The SD CARD process picks up on ShutDown, and
            issues it’s own “sd.unmount.prep” event. It too can use a
            ‘done’ callback to know when that event has been delivered.</li>
          <li class="">Now that the ShutDown event has been delivered,
            the ‘done’ callback for that is fired and “module reset”
            things everything is shutdown.</li>
          <li class="">But, the “sd.unmount.prep” event has not been
            delivered yet, and the sd card has not been unmounted.</li>
        </ul>
        <div><br class="">
        </div>
        <div>This is different to the “sd unmount” case, where sending
          “sd.unmount.prep” and then doing the actual unmount on the
          callback is fine. Although, I am still unsure of how that will
          work in practice; as we really need to keep the command
          blocked until that unmount has run to completion.</div>
        <div><br class="">
        </div>
        <div>Ideas? Without making it overly complex?</div>
        <div><br class="">
        </div>
        <div>Regards, Mark</div>
        <div><br class="">
          <blockquote type="cite" class="">
            <div class="">On 30 Apr 2018, at 3:13 PM, Michael Balzer
              <<a href="mailto:dexter@expeedo.de" class="" moz-do-not-send="true">dexter@expeedo.de</a>> wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <meta http-equiv="Content-Type" content="text/html;
                charset=utf-8" class="">
              <div text="#000000" bgcolor="#FFFFFF" class=""> Sorry for
                not being clear, it's early over here. My point was:<br class="">
                <br class="">
                Unmounting the SD card should be a separate process,
                usable without doing a complete shutdown.<br class="">
                <br class="">
                Regarding a fixed delay, I would rather proceed to the
                actual unmount  as soon as the "unmounting" event has
                been processed by all listeners, i.e. on the event's
                done callback. Unmounting listeners just need to close
                their files, no need to introduce delays there.<br class="">
                <br class="">
                Regards,<br class="">
                Michael<br class="">
                <br class="">
                <br class="">
                <div class="moz-cite-prefix">Am 30.04.2018 um 08:41
                  schrieb Mark Webb-Johnson:<br class="">
                </div>
                <blockquote type="cite" cite="mid:B09911C9-0CEB-4423-B550-6611B8C3CDF4@webb-johnson.net" class="">
                  <meta http-equiv="Content-Type" content="text/html;
                    charset=utf-8" class="">
                  <div class=""><br class="">
                  </div>
                  That is why I was thinking of two signals:
                  <div class=""><br class="">
                  </div>
                  <div class="">
                    <ol class="MailOutline">
                      <li class="">“ShuttingDown”. This would be sent
                        when the shutdown process was initiated. My
                        suggestion is to then delay 20 seconds (to give
                        peripherals time to cleanly shutdown) before
                        proceeding to the next stage. The signal is
                        intended to ask peripherals and systems to
                        cleanly prepare for shutdown.<br class="">
                        <br class="">
                      </li>
                      <li class="">“ShutDown”. This would be sent 5
                        seconds before the actual shutdown. The signal
                        is intended to ask peripherals and systems to
                        prepare for shutdown now.</li>
                    </ol>
                    <div class=""><br class="">
                    </div>
                    <div class="">I will implement the basics of this
                      tonight.</div>
                    <div class=""><br class="">
                    </div>
                    <div class="">Regards, Mark.</div>
                    <div class=""><br class="">
                      <blockquote type="cite" class="">
                        <div class="">On 30 Apr 2018, at 2:32 PM,
                          Michael Balzer <<a href="mailto:dexter@expeedo.de" class="" moz-do-not-send="true">dexter@expeedo.de</a>>
                          wrote:</div>
                        <br class="Apple-interchange-newline">
                        <div class="">
                          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
                          <div text="#000000" bgcolor="#FFFFFF" class="">
                            Yes, a general shutdown signal scheme makes
                            sense, but still also a separate SD
                            unmounting signal to be able to remove just
                            the SD card with a single command.<br class="">
                            <br class="">
                            Regards,<br class="">
                            Michael<br class="">
                            <br class="">
                            <br class="">
                            <div class="moz-cite-prefix">Am 30.04.2018
                              um 04:28 schrieb Mark Webb-Johnson:<br class="">
                            </div>
                            <blockquote type="cite" cite="mid:B0392199-B3EA-49AC-9CAD-A59991ACB4C8@webb-johnson.net" class="">
                              <meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
                              Writing the code last night, it seemed
                              that the shutting down of wifi/simcom/etc
                              was messy.
                              <div class=""><br class="">
                              </div>
                              <div class="">Perhaps we need to have new
                                signals “ShuttingDown” and “ShutDown”,
                                then make the components responsible for
                                this? So, for example, wifi powers off,
                                server v2 disconnects, logging stops
                                logging to SD, etc, on “ShuttingDown”.
                                Then SD unmounts on “ShutDown”.</div>
                              <div class=""><br class="">
                              </div>
                              <div class="">A better solution?</div>
                              <div class=""><br class="">
                              </div>
                              <div class="">Regards, Mark.</div>
                              <div class="">
                                <div class=""><br class="">
                                  <div class="">
                                    <blockquote type="cite" class="">
                                      <div class="">On 30 Apr 2018, at
                                        6:31 AM, Michael Balzer <<a href="mailto:dexter@expeedo.de" class="" moz-do-not-send="true">dexter@expeedo.de</a>>
                                        wrote:</div>
                                      <br class="Apple-interchange-newline">
                                      <div class="">
                                        <meta http-equiv="Content-Type" content="text/html;
                                          charset=utf-8" class="">
                                        <div text="#000000" bgcolor="#FFFFFF" class="">
                                          Attention: performing an
                                          AutoFlash just killed my SD
                                          filesystem.<br class="">
                                          <br class="">
                                          Possibly just by chance and I
                                          was lucky all the reboots
                                          before, but I think we really
                                          need to close all SD files
                                          before reboot -- see issue
                                          #97.<br class="">
                                          <br class="">
                                          FYI: the SD could be restored
                                          by a simple fsck, no data
                                          loss. My Linux system also
                                          could mount the SD before the
                                          fsck. The module was stuck in
                                          the mount attempt.<br class="">
                                          <br class="">
                                          Regards,<br class="">
                                          Michael<br class="">
                                          <br class="">
                                          <br class="">
                                          <div class="moz-cite-prefix">Am
                                            29.04.2018 um 16:39 schrieb
                                            Mark Webb-Johnson:<br class="">
                                          </div>
                                          <blockquote type="cite" cite="mid:8A101897-B19C-4FEC-89D5-8D00304BC65F@webb-johnson.net" class="">
                                            <meta http-equiv="Content-Type" content="text/html;
                                              charset=utf-8" class="">
                                            <div class=""><br class="">
                                            </div>
                                            The last piece of the puzzle
                                            falls into place.
                                            <div class=""><br class="">
                                            </div>
                                            <blockquote style="margin: 0
                                              0 0 40px; border: none;
                                              padding: 0px;" class=""><font class="" face="Andale
                                                Mono"><span style="font-size:
                                                  14px;" class="">OVMS#
                                                  config set auto ota
                                                  yes</span></font></blockquote>
                                            <blockquote style="margin: 0
                                              0 0 40px; border: none;
                                              padding: 0px;" class=""><font class="" face="Andale
                                                Mono"><span style="font-size:
                                                  14px;" class="">OVMS#
                                                  config set ota
                                                  auto.hour 2</span></font></blockquote>
                                            <div class="">
                                              <div class=""><br class="">
                                              </div>
                                              <div class="">Module will
                                                wake up sometime between
                                                2am and 3am, and if wifi
                                                is available it will
                                                check the available
                                                server version
                                                (according to OTA tag
                                                and server url). If the
                                                server has a later
                                                version, the module will
                                                download and flash that
                                                new version then reboot
                                                into it.</div>
                                              <div class=""><br class="">
                                              </div>
                                              <div class="">I’ve also
                                                brought in the
                                                strverscmp function for
                                                GNU library, which is
                                                generally useful for
                                                comparing versions.</div>
                                              <div class=""><br class="">
                                              </div>
                                              <div class="">Enjoy.</div>
                                              <div class=""><br class="">
                                              </div>
                                              <div class="">Regards,
                                                Mark.</div>
                                              <div class=""><br class="">
                                                <blockquote type="cite" class="">
                                                  <div class="">Begin
                                                    forwarded message:</div>
                                                  <br class="Apple-interchange-newline">
                                                  <div style="margin-top:
                                                    0px; margin-right:
                                                    0px; margin-bottom:
                                                    0px; margin-left:
                                                    0px;" class=""><span style="font-family: -webkit-system-font, "Helvetica Neue",
                                                      Helvetica,
                                                      sans-serif;" class=""><b class="">From: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica,
                                                      sans-serif;" class="">GitHub
                                                      <<a href="mailto:noreply@github.com" class="" moz-do-not-send="true">noreply@github.com</a>><br class="">
                                                    </span></div>
                                                  <div style="margin-top:
                                                    0px; margin-right:
                                                    0px; margin-bottom:
                                                    0px; margin-left:
                                                    0px;" class=""><span style="font-family: -webkit-system-font, "Helvetica Neue",
                                                      Helvetica,
                                                      sans-serif;" class=""><b class="">Subject:
                                                      </b></span><span style="font-family:
-webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class=""><b class="">[openvehicles/Open-Vehicle-Monitoring-System-3]
                                                        1a4301: Bring in
                                                        GNU strverscmp
                                                        component, and
                                                        test comman...</b><br class="">
                                                    </span></div>
                                                  <div style="margin-top:
                                                    0px; margin-right:
                                                    0px; margin-bottom:
                                                    0px; margin-left:
                                                    0px;" class=""><span style="font-family: -webkit-system-font, "Helvetica Neue",
                                                      Helvetica,
                                                      sans-serif;" class=""><b class="">Date: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica,
                                                      sans-serif;" class="">29 April
                                                      2018 at 10:23:54
                                                      PM HKT<br class="">
                                                    </span></div>
                                                  <div style="margin-top:
                                                    0px; margin-right:
                                                    0px; margin-bottom:
                                                    0px; margin-left:
                                                    0px;" class=""><span style="font-family: -webkit-system-font, "Helvetica Neue",
                                                      Helvetica,
                                                      sans-serif;" class=""><b class="">To: </b></span><span style="font-family: -webkit-system-font, Helvetica Neue, Helvetica,
                                                      sans-serif;" class=""><a href="mailto:mark@webb-johnson.net" class="" moz-do-not-send="true">mark@webb-johnson.net</a><br class="">
                                                    </span></div>
                                                  <div style="margin-top:
                                                    0px; margin-right:
                                                    0px; margin-bottom:
                                                    0px; margin-left:
                                                    0px;" class=""><span style="font-family: -webkit-system-font, "Helvetica Neue",
                                                      Helvetica,
                                                      sans-serif;" class=""><b class="">Reply-To:
                                                      </b></span><span style="font-family:
-webkit-system-font, Helvetica Neue, Helvetica, sans-serif;" class="">GitHub
                                                      <<a href="mailto:noreply@github.com" class="" moz-do-not-send="true">noreply@github.com</a>><br class="">
                                                    </span></div>
                                                  <br class="">
                                                  <div class="">
                                                    <div class="">
                                                       Branch:
                                                      refs/heads/master<br class="">
                                                       Home:   <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3" class="" moz-do-not-send="true">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3</a><br class="">
                                                       Commit:
                                                      1a4301d7ca1c7ed619109dfcb2e832a599af7dda<br class="">
                                                           <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/1a4301d7ca1c7ed619109dfcb2e832a599af7dda" class="" moz-do-not-send="true">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/1a4301d7ca1c7ed619109dfcb2e832a599af7dda</a><br class="">
                                                       Author: Mark
                                                      Webb-Johnson <<a href="mailto:mark@webb-johnson.net" class="" moz-do-not-send="true">mark@webb-johnson.net</a>><br class="">
                                                       Date:
                                                        2018-04-29 (Sun,
                                                      29 Apr 2018)<br class="">
                                                      <br class="">
                                                       Changed paths:<br class="">
                                                         A
                                                      vehicle/OVMS.V3/components/strverscmp/component.mk<br class="">
                                                         A
                                                      vehicle/OVMS.V3/components/strverscmp/src/strverscmp.c<br class="">
                                                         A
                                                      vehicle/OVMS.V3/components/strverscmp/src/strverscmp.h<br class="">
                                                         M
                                                      vehicle/OVMS.V3/main/test_framework.cpp<br class="">
                                                      <br class="">
                                                       Log Message:<br class="">
                                                       -----------<br class="">
                                                       Bring in GNU
                                                      strverscmp
                                                      component, and
                                                      test command<br class="">
                                                      <br class="">
                                                      <br class="">
                                                       Commit:
                                                      58fa1b57448d3491889e3d1d3f487e475d036c92<br class="">
                                                           <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/58fa1b57448d3491889e3d1d3f487e475d036c92" class="" moz-do-not-send="true">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/58fa1b57448d3491889e3d1d3f487e475d036c92</a><br class="">
                                                       Author: Mark
                                                      Webb-Johnson <<a href="mailto:mark@webb-johnson.net" class="" moz-do-not-send="true">mark@webb-johnson.net</a>><br class="">
                                                       Date:
                                                        2018-04-29 (Sun,
                                                      29 Apr 2018)<br class="">
                                                      <br class="">
                                                       Changed paths:<br class="">
                                                         M
                                                      vehicle/OVMS.V3/components/ovms_ota/src/ovms_ota.cpp<br class="">
                                                         M
                                                      vehicle/OVMS.V3/components/ovms_ota/src/ovms_ota.h<br class="">
                                                      <br class="">
                                                       Log Message:<br class="">
                                                       -----------<br class="">
                                                       AutoFlash
                                                      implementation:<br class="">
                                                      Config
                                                      auto[ota]=yes<br class="">
                                                      Config
                                                      ota[auto.hour]=2<br class="">
                                                      <br class="">
                                                      <br class="">
                                                      Compare: <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/compare/87d80c30825b...58fa1b57448d" class="" moz-do-not-send="true">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/compare/87d80c30825b...58fa1b57448d</a></div>
                                                  </div>
                                                </blockquote>
                                              </div>
                                              <br class="">
                                            </div>
                                            <br class="">
                                            <fieldset class="mimeAttachmentHeader"></fieldset>
                                            <br class="">
                                            <pre class="" wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
                                          </blockquote>
                                          <br class="">
                                          <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
                                        </div>
_______________________________________________<br class="">
                                        OvmsDev mailing list<br class="">
                                        <a href="mailto:OvmsDev@lists.openvehicles.com" class="" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a><br class="">
                                        <a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br class="">
                                      </div>
                                    </blockquote>
                                  </div>
                                  <br class="">
                                </div>
                              </div>
                              <br class="">
                              <fieldset class="mimeAttachmentHeader"></fieldset>
                              <br class="">
                              <pre class="" wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
                            </blockquote>
                            <br class="">
                            <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
                          </div>
_______________________________________________<br class="">
                          OvmsDev mailing list<br class="">
                          <a href="mailto:OvmsDev@lists.openvehicles.com" class="" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a><br class="">
                          <a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br class="">
                        </div>
                      </blockquote>
                    </div>
                    <br class="">
                  </div>
                  <br class="">
                  <fieldset class="mimeAttachmentHeader"></fieldset>
                  <br class="">
                  <pre class="" wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
                </blockquote>
                <br class="">
                <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
              </div>
              _______________________________________________<br class="">
              OvmsDev mailing list<br class="">
              <a href="mailto:OvmsDev@lists.openvehicles.com" class="" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a><br class="">
              <a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br class="">
            </div>
          </blockquote>
        </div>
        <br class="">
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
  

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>OvmsDev mailing list</span><br><span><a href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a></span><br><span><a href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a></span><br></div></blockquote></body></html>