Sfoglia il codice sorgente

added ymodem command to example

stefan 9 mesi fa
parent
commit
0dbe00354d
1 ha cambiato i file con 47 aggiunte e 0 eliminazioni
  1. 47 0
      example/main.c

+ 47 - 0
example/main.c

@@ -175,6 +175,52 @@ static shellmatta_retCode_t busy(shellmatta_handle_t handle, const char *argumen
 }
 shellmatta_cmd_t busyCommand = {"busy", NULL, NULL, NULL, busy, NULL, NULL};
 
+shellmatta_retCode_t ret = SHELLMATTA_OK;
+
+void ymodemCallbackCancel() {
+    return;
+}
+
+void ymodemCallbackReceivePacket() {
+    return;
+}
+
+void ymodemCallbackTransmissionComplete() {
+    ret = SHELLMATTA_OK;
+    return;
+}
+
+
+uint8_t ymodemBuffer[1024u] = {0};
+uint32_t ymodemFileSize = 0;
+uint16_t ymodemPacketSize = 0;
+shellmatta_ymodem_callbacks_t ymodemCallbacks = {
+    ymodemCallbackCancel,
+    ymodemCallbackReceivePacket,
+    ymodemCallbackTransmissionComplete
+};
+
+
+static shellmatta_retCode_t ymodem(shellmatta_handle_t handle, const char *arguments, uint32_t length)
+{
+    (void)arguments;
+    (void)length;
+
+    if (SHELLMATTA_OK == ret)
+    {
+        shellmatta_printf(handle, "Starting ymodem session\r\n");
+        shellmatta_ymodem(handle,
+                        ymodemBuffer,
+                        &ymodemFileSize,
+                        &ymodemPacketSize,
+                        ymodemCallbacks);
+        ret = SHELLMATTA_CONTINUE;
+    }
+
+    return ret;
+}
+shellmatta_cmd_t ymodemCommand = {"ymodem", NULL, NULL, NULL, ymodem, NULL};
+
 
 shellmatta_retCode_t writeFct(const char* data, uint32_t length)
 {
@@ -220,6 +266,7 @@ int main(int argc, char **argv)
     shellmatta_addCmd(handle, &resetCommand);
     shellmatta_addCmd(handle, &continuousCommand);
     shellmatta_addCmd(handle, &busyCommand);
+    shellmatta_addCmd(handle, &ymodemCommand);
 
 
     shellmatta_auth_user_t userList[] = {