-
Notifications
You must be signed in to change notification settings - Fork 13.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
FTP request opcode #1357
FTP request opcode #1357
Conversation
Extra crc not needed because mavlink already has crc16.
This PR implement my suggestions from #1345. |
Don't understand why you need #1? Sequence numbers tell you if you are getting correct responses back and from what request.
|
At least in open() i must know request opcode, now i guess it from size. |
For req_opcode: You have to know what sort of a response you are waiting on. If a client sends an Open, you assume the Ack you are getting back is for an Open. The sequence numbers provide a decent level of validation that the Ack or Nak is associated with the correct command. You send an Open with sequence number "n" and get back "Ack/Nak" with sequence number "n+1". See the QGroundControl client code for example. I can see how adding req_opcode adds an additional level of validation, but other than that I don't see what it does. Are you trying to allow more than one command from the same client to be sent without waiting for a response to come back first? The protocol isn't set up to have a client send multiple commands without waiting for a response back. Even adding a req_opcode field won't allow for that any more reliably than just the current sequence number setup. At least not as far as I can see it. Maybe I need more explanation as to what you are trying to accomplish with this. For crc32, and opcode 128: These are great changes. Thanks. You need to update and pass the unit test as well though. See src/modules/mavlink/mavlink_tests. Build using "make px4fmu-v2_test". Flash with that build and run mavlink_tests from nsh. |
uint8_t padding[3]; ///< 32 bit aligment padding | ||
uint32_t crc32; ///< CRC for entire Request structure, with crc32 and padding set to 0 | ||
uint8_t req_opcode; ///< Request opcode returned in kRspAck, kRspNak message | ||
uint16_t reserved[3]; ///< reserved area |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change the name from "padding" to "reserved" as well as change the comment? This makes it less clear as to why this is here. I can see "reserved" to keep people from touching this, but you should leave the comment about 32-bit alignment. Also the padding should now be 2 uint8_t's since you added one more byte to the structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the padding in the reserved as to leave room for crc32, for further development. So reserved is padding[2] + uint32_t.
Maybe better is to remove this space and leave padding only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header needs to be as small as possible in order to get as many bytes for data as we can. Downloading a file in as few packets as possible is critical. Given that I don't think reserving space for future changes is good in this case.
I mean that open() handle both kCmdOpen and kCmdCreate. And potentially kCmd for open for write. |
In order to write a client which handles all error cases, it will need to remember which command the ack is for. Otherwise an incorrectly written server implementation could return kCmdCreateFile in req_opcode in response to a kCmdOpenFile request. If your client just uses req_opcode on the Ack to determine what to do, strange things are going to happen in that case. I like the validation aspect of it, since it provides even better error checking on Acks. So I suggest leave it in. But I wouldn't depend on it to drive your client side state machine implementation. |
@DonLakeFlyer unit-test failed on list operation, on response1, response2 works fine.
|
Seems that this test not correct, list can return dirent in other order. Dirty hack: inside printf("RS: ");
for (int i=0; i < reply->size; i++)
printf("%c", (reply->data[i])? : '|');
printf("\n"); Result:
And i prefer to ignore |
|
||
payload->crc32 = _payload_crc32(payload); | ||
payload->padding[0] = 0; | ||
payload->padding[1] = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment on not needing to do this from QGC side of things.
Awesome. Thanks a ton for these changes both here and in QGroundControl. I saw the unit test failure you are seeing as well. I have a separate pull which fixes this already in the works. I'll also pull out "." and ".." returns. Other than removing the padding sets this is good to go. Once that is done I'll merge on both sides. |
@DonLakeFlyer done. |
This PR do: