Sfoglia il codice sorgente

added some function to have more control over ymodem from higher layer

Fischer, Simon | Friedrich Lütze GmbH 1 anno fa
parent
commit
19b750177a
3 ha cambiato i file con 30 aggiunte e 1 eliminazioni
  1. 4 0
      api/shellmatta.h
  2. 20 1
      src/shellmatta.c
  3. 6 0
      src/shellmatta_ymodem.h

+ 4 - 0
api/shellmatta.h

@@ -337,6 +337,10 @@ uint8_t shellmatta_ymodem(  shellmatta_handle_t             handle,
 void shellmatta_ymodem_end( shellmatta_handle_t             handle,
                             bool                            doCancel);
 
+void shellmatta_ymodem_set_enable(bool                      doEnable);
+
+bool shellmatta_ymodem_is_active(void);
+
 #endif
 
 /** @} */

+ 20 - 1
src/shellmatta.c

@@ -139,7 +139,7 @@ static shellmatta_retCode_t shellmatta_processDataInt(shellmatta_handle_t     ha
                     if (yModemState == WAIT_FOR_START)
                     {
                         /** -# explicitly reset ymodem with cancel, if it was active */
-                        // shellmatta_ymodem_reset(handle, true);
+                        shellmatta_ymodem_reset(handle, true);
                     }
                 }
                 ret = SHELLMATTA_OK;
@@ -957,6 +957,25 @@ uint8_t shellmatta_ymodem(  shellmatta_handle_t             handle,
 void shellmatta_ymodem_end(shellmatta_handle_t handle, bool doCancel)
 {
     shellmatta_ymodem_reset(handle, doCancel);
+    /* clear any possibly leftover inputs */
+    utils_clearInput((shellmatta_instance_t*)handle);
+}
+
+void shellmatta_ymodem_set_enable(bool doEnable)
+{
+    if (doEnable) 
+    {
+        shellmatta_ymodem_enable();
+    }
+    else
+    {
+        shellmatta_ymodem_disable();
+    }
+}
+
+bool shellmatta_ymodem_is_active(void)
+{
+    return shellmatta_ymodem_get_current_datatype() != YMODEM_NONE;
 }
 
 /** @} */

+ 6 - 0
src/shellmatta_ymodem.h

@@ -87,4 +87,10 @@ void shellmatta_ymodem_check_packet(    shellmatta_handle_t handle);
 void shellmatta_ymodem_reset(           shellmatta_handle_t handle,
                                         bool                doCancel);
 
+shellmatta_ymodem_datatype_t shellmatta_ymodem_get_current_datatype(void);
+
+void shellmatta_ymodem_enable(void);
+
+void shellmatta_ymodem_disable(void);
+
 #endif /* _SHELLMATTA_YMODEM_H_ */