-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fast binary file transfer to SD card option #12249
Conversation
I'd suggest to separate the BinaryStream into its own files, to limit the queue.cpp fle size and overall complexity. (And Good Job p3p !) |
yea sorting out the feature configuration and tidying up was on the agenda for after initial review, the feature is pretty much completely encapsulated in its class so that's not a problem. @thinkyhead It would probably be better just to conditional compile the whole thing on whether the sdcard is enabled rather than pick out the individual parts unless you have plans for alternate steam types. |
seems that there's a bug where sometimes the filename is wrong in the transfer completed message, which would mean on error it would delete the wrong file, so I may have misunderstood how and when this variable is initialised. |
If you use |
Using a standard gcode argument B followed by the filename is an artefact of an earlier design where you had to send the number of blocks that would be transferred, I left it in as I preferred the simplicity of design, and made it easy not to break backwards compatibility. What format would you prefer?, |
Use |
Just curious, does this do error checking and recovery? Serial comms are full of errors. If not, I wonder if it makes sense to reuse a historical protocol, such as ZModem that already solves a lot of those problems. |
It would be pretty useless without error checking ;) considering I'm using it for transmitting firmware, each packet has a 16bit checksum, a size that can be varied depending on transmission errors, and there is a resend packet request mechanism. In order to keep buffer space to a minimum the protocol does not allow out of order sending so each packet must be acked before the next is sent. The main benefit of ZMODEM is the multiple packets in transit simultaneously which is not applicable here, although adding the packet id to the ack would allow it given enough memory it over complicates matters. |
@p3p: Ah. Okay. Glad you already have that covered :)
Sounds like you already looked into the pros and cons of using it. I don't know much about ZModem other than I remembered using it back in the stone ages :) |
6a51a2a
to
ef78419
Compare
But how do you use it?
|
As far as I understand, you need to use the transfer.py sample linked in first message to manage the host/sender side, or an other compatible implementation. |
Ok thank's i try now... |
@MagoKimbra Indeed as @TheSFReader said it will require host support, the python script in the PR description is an example of the host side of the protocol. This was merged faster than expected and was only submitted as a "concept", I expected a little more feedback from users before it was merged. It hasn't really been tested much on normal UART or USB to UART bridges, I needed a way to transfer my firmware over the serial connection and as my MCU has native USB CDC that's what I tested with, as such I don't really know what performance you will get, on CDC I get 80 - 100KiB/s. Any feedback is welcome. |
Excuse me, I did not understand that the host's support was needed, I thought it was enough to add B1 to the M28 command to use it ... |
Merging things is a great way to get feedback. Otherwise very few ever notice most PRs. |
@p3p Hi, Friend, I want to use the FAST_FILE_TRANSFER function. I use the file transfer.py to test the process. Actully there are something werid thing.
I have adde some more debug message.The packet(2) was resend, Actually there are 40 bytes lost, this situation is always happened, And the Speed is limited be this error; I think There may be some Problem; |
I have some updates to the protocol to push upstream that help with stream recovery and reliability but I'm not sure it will help you as you seem to be dropping data at the hardware level? What type of serial connection are you using? |
It looks like there is a little bug in transfer.py line 82 should be
and line 100 |
4.3MB in 45s it starts to be usable :)
|
@rafaljot Sorry about that was sure I'd updated the host example when I changed the connect response to ascii. (mumbles something about finishing the updates mentioned in my previous post .. march isn't that long ago right?) |
@luc-github @p3p |
I have a PR that improves stream recovery ready (superseded) but I may wait until I finish the changes I'm working on to generalise the transport layer, hopefully finalising the protocol before anyone uses it in a host if they ever do ^^. |
Description
Adds support for transferring arbitrary files over the serial connection from host software.
I implemented a simple custom protocol, any input into improvements are welcome, I have written similar things in the past but this wasn't exactly thoroughly designed (there may have been a doodle), its a very simple packet structure and keeps the host side of the communication as ASCII (2 byte command tokens) apart from a 16bit max packet size value transferred as part of the stream initialisation.
The host side of the protocol is implemented in the python example attached.
(superseded)
Benefits
Ability to transfer binaries over the serial connection on devices that can be flashed from sd card and
due to less overhead and constant maximum packet size it improves transfer rate of gcode files.
Until this has host support it will be of very limited use, and we would need to report its availability.