{"action":"created","issue":{"url":"https://api.github.com/repos/contiki-os/contiki/issues/1100","labels_url":"https://api.github.com/repos/contiki-os/contiki/issues/1100/labels{/name}","comments_url":"https://api.github.com/repos/contiki-os/contiki/issues/1100/comments","events_url":"https://api.github.com/repos/contiki-os/contiki/issues/1100/events","html_url":"https://github.com/contiki-os/contiki/issues/1100","id":85144323,"number":1100,"title":"CoAP block size transfer parse error","user":{"login":"arthurfabre","id":3017009,"avatar_url":"https://avatars.githubusercontent.com/u/3017009?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurfabre","html_url":"https://github.com/arthurfabre","followers_url":"https://api.github.com/users/arthurfabre/followers","following_url":"https://api.github.com/users/arthurfabre/following{/other_user}","gists_url":"https://api.github.com/users/arthurfabre/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurfabre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurfabre/subscriptions","organizations_url":"https://api.github.com/users/arthurfabre/orgs","repos_url":"https://api.github.com/users/arthurfabre/repos","events_url":"https://api.github.com/users/arthurfabre/events{/privacy}","received_events_url":"https://api.github.com/users/arthurfabre/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-04T15:20:55Z","updated_at":"2015-09-12T16:14:03Z","closed_at":"2015-09-12T16:14:03Z","body":"Using Contiki master on a Zolertia Z1, I'm experiencing errors with CoAP block sizes.\r\n\r\nIf a client GETs a resource (without specifying any block2 options) whose handler requests the use of blocks (by setting the offset variable), subsequent messages from the client (to request the additional blocks) will contain block2 options (such as the block_size).\r\nThe block_size option is not handled correctly, which leads to a wrong offset, which causes the wrong data to be sent.\r\n\r\nI've verified using WireShark that the expected block_size is correctly sent by the client, but the block_size received by `er-coap-engine.c` is incorrect.\r\n\r\nAll of the code that deals with the block2 option parsing appears to be correct.\r\nWeirdly enough, adding a `printf` statement as follows on line `644` of `er-coap.c` (`apps/er-coap/`) resolves the issue.\r\n`printf(\"%d\\n\", coap_pkt->block2_size);`\r\n\r\nI'm more than willing to look into this further, but I have no idea where to start - this is very weird.\r\n\r\nA zip file containing logs obtained over serial of a working and non working sequence of messages, as well as the associated wireshark packet dumps and a patch to add the print statement in can be found [here](https://files.arthurfabre.com/?t=1e01192f02c0bfc0ce9175fb61be28ee)."},"comment":{"url":"https://api.github.com/repos/contiki-os/contiki/issues/comments/139792197","html_url":"https://github.com/contiki-os/contiki/issues/1100#issuecomment-139792197","issue_url":"https://api.github.com/repos/contiki-os/contiki/issues/1100","id":139792197,"user":{"login":"arthurfabre","id":3017009,"avatar_url":"https://avatars.githubusercontent.com/u/3017009?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurfabre","html_url":"https://github.com/arthurfabre","followers_url":"https://api.github.com/users/arthurfabre/followers","following_url":"https://api.github.com/users/arthurfabre/following{/other_user}","gists_url":"https://api.github.com/users/arthurfabre/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurfabre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurfabre/subscriptions","organizations_url":"https://api.github.com/users/arthurfabre/orgs","repos_url":"https://api.github.com/users/arthurfabre/repos","events_url":"https://api.github.com/users/arthurfabre/events{/privacy}","received_events_url":"https://api.github.com/users/arthurfabre/received_events","type":"User","site_admin":false},"created_at":"2015-09-12T16:14:03Z","updated_at":"2015-09-12T16:14:03Z","body":"This seems to have been fixed by 5403b2a211034144137ab0ec52b995a3c23d8e37, looking back on this I'm not quite sure how I came to the conclusion that `printf` fixed it, seeing as I had already fixed the default block size."}}