shellmatta_ymodem.dox 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /**
  2. @page shellmatta_ymodem Shellmatta ymodem
  3. To be able to pass binary files to the shellmatta there is a ymodem module
  4. implemented.
  5. The ymodem reception can be started from a shellmatta command and handles
  6. the handshaking as well as the data transmission.
  7. As the shellmatta does not use dynamic memory every packet is passed
  8. directly to the application using a callback.
  9. Only the currently received packet is stored in the shellmatta internally.
  10. In order to transmit the start characters to the sender you need to poll the
  11. shellmatta_processData() function cyclically even if no new data has been
  12. received.
  13. Do this in 0.1s - 1s periods (depending on the latency you are after).
  14. When the transmission is complete the shellmatta requires to be polled
  15. #YMODEM_POLL_NUMBER times. This ensures a short wait time to flush all
  16. unwanted bytes from the transmitter.
  17. The shellmatta_ymodem_init() function will return and the command it was
  18. called from will not be executed again. The rest of the ymodem processing
  19. will be handled by the shellmatta. The data will be passed using the
  20. callbacks registered during the start.
  21. To cancel the ymodem (e.g. timeout) just call shellmatta_ymodem_cancel()
  22. @section shellmatta_ymodem_sequence Basic sequence
  23. @startuml
  24. Application -> Shellmatta: shellmatta_ymodem_init()
  25. Shellmatta -> Host: send C to start transmission
  26. Shellmatta -> Application: return
  27. loop until ymodem transmission starts (or is canceled)
  28. Application -> Shellmatta: shellmatta_processData(null)
  29. Shellmatta -> Host: send C to start transmission
  30. end
  31. Application -> Shellmatta: shellmatta_processData(first packet)
  32. Shellmatta -> Application: packetHeader(fileSize, FileName) callback
  33. loop until shellmatta transmission is complete
  34. Host -> Shellmatta: Data transmission
  35. Shellmatta -> Application: packetRcv() callback
  36. end
  37. Shellmatta -> Application: transmissionComplete() callback
  38. @enduml
  39. While the ymodem is active no command can be executed.
  40. When the ymodem is canceled from the Host the data received afterwards will
  41. be processed as usual.
  42. @warning Ymodem cannot cooperate with optional transport layer.
  43. When the transport layer is enabled but not mandatory it is
  44. forced to stay in the mode it was when the ymodem transfer
  45. starts.
  46. When the transport layer was active it has to keep active.
  47. If it is inactive it cannot be activated during the ymodem
  48. transfer.
  49. @section shellmatta_ymodem_internal_buffer Internal buffer
  50. To save some memory you can use the shellmatta ymodem module using the
  51. internal buffer which usually is used to cache normal input before
  52. processing it.
  53. Just set the recvBuffer to NULL in #shellmatta_ymodem_init calls.
  54. @warning Ensure that your shellmattas buffer is at least
  55. #YMODEM_PACKET_SIZE_1K large to fit the ymodem packet.
  56. This is checked during initialization.
  57. @section shellmatta_ymodem_paused_mode Paused mode
  58. When the application requires time to process the currently received packet
  59. the application can call #shellmatta_ymodem_pause from the callbacks.
  60. This will prevent the shellmatta from sending the ACK to the sender.
  61. When the processing is done just call #shellmatta_ymodem_resume.
  62. */