{"action":"opened","issue":{"url":"https://api.github.com/repos/thijse/Arduino-CmdMessenger/issues/4","labels_url":"https://api.github.com/repos/thijse/Arduino-CmdMessenger/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/thijse/Arduino-CmdMessenger/issues/4/comments","events_url":"https://api.github.com/repos/thijse/Arduino-CmdMessenger/issues/4/events","html_url":"https://github.com/thijse/Arduino-CmdMessenger/issues/4","id":103885416,"number":4,"title":"Reading a string messes up all the arguments.","user":{"login":"Davideddu","id":1151321,"avatar_url":"https://avatars.githubusercontent.com/u/1151321?v=3","gravatar_id":"","url":"https://api.github.com/users/Davideddu","html_url":"https://github.com/Davideddu","followers_url":"https://api.github.com/users/Davideddu/followers","following_url":"https://api.github.com/users/Davideddu/following{/other_user}","gists_url":"https://api.github.com/users/Davideddu/gists{/gist_id}","starred_url":"https://api.github.com/users/Davideddu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Davideddu/subscriptions","organizations_url":"https://api.github.com/users/Davideddu/orgs","repos_url":"https://api.github.com/users/Davideddu/repos","events_url":"https://api.github.com/users/Davideddu/events{/privacy}","received_events_url":"https://api.github.com/users/Davideddu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-29T21:48:50Z","updated_at":"2015-08-29T21:48:50Z","closed_at":null,"body":"I've been using CmdMessenger for a while and it seemed to work, however my current application requires the reception of a string through serial. Here's the function:\r\n\r\n```c++\r\nvoid onBtChName() {\r\n  sendAck(kACK, kBT_CHNAME, F(\"Storing new name.\"));\r\n  uint8_t len = constrain(cmdMessenger.readInt16Arg(), 0, 30);\r\n  cmdMessenger.copyStringArg(bt_newname, len+1);\r\n  Serial.print(\"New name \");\r\n  Serial.write(bt_newname, len);\r\n  Serial.println(len);\r\n  bt_newnamelen = len;\r\n  bt_chname = true;\r\n  sendAck(kDONE, kBT_CHNAME, F(\"New name stored. Please commit.\"));\r\n}\r\n```\r\n\r\nThis is the callback attached to kBT_CHNAME, which is command 15. I'd expect it to read two arguments, an integer and a string. However it does not work. If I comment out the string reading part, everything works fine (ex. if I send `15,12,34,56,78;`, the `len` variable would contain 12 as I would expect). However, if I also read the string (which is odd, as the string is read *after* the integer), it skips two arguments. So while `15,9,Davideddu;` does not work, `15,0,0,9,Davideddu;` does. Another example, if I send `15,12,34,56,78;` len would be set to 56 (actually 30 because of constrain, but it doesn't really matter) and bt_newname would contain 78 + 28 bytes of crap.\r\n\r\nThis is a pretty odd bug.\r\n\r\nP.S.: I wrote a python port of CmdMessenger with a similar API that, however, tries to make use of Python-specific features. you can find it [here](https://github.com/Davideddu/python-cmdmessenger). I'll document it and add a readme at some point."}}