{"action":"opened","issue":{"url":"https://api.github.com/repos/fakufaku/CmdArduino/issues/1","labels_url":"https://api.github.com/repos/fakufaku/CmdArduino/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/fakufaku/CmdArduino/issues/1/comments","events_url":"https://api.github.com/repos/fakufaku/CmdArduino/issues/1/events","html_url":"https://github.com/fakufaku/CmdArduino/issues/1","id":85697759,"number":1,"title":"Sending inadvertent '\\r\\n' (Carriage Return & Line Feed) breaks CmdArduino.","user":{"login":"DarrellStuff","id":12771240,"avatar_url":"https://avatars.githubusercontent.com/u/12771240?v=3","gravatar_id":"","url":"https://api.github.com/users/DarrellStuff","html_url":"https://github.com/DarrellStuff","followers_url":"https://api.github.com/users/DarrellStuff/followers","following_url":"https://api.github.com/users/DarrellStuff/following{/other_user}","gists_url":"https://api.github.com/users/DarrellStuff/gists{/gist_id}","starred_url":"https://api.github.com/users/DarrellStuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DarrellStuff/subscriptions","organizations_url":"https://api.github.com/users/DarrellStuff/orgs","repos_url":"https://api.github.com/users/DarrellStuff/repos","events_url":"https://api.github.com/users/DarrellStuff/events{/privacy}","received_events_url":"https://api.github.com/users/DarrellStuff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-06T04:55:38Z","updated_at":"2015-06-06T04:55:38Z","closed_at":null,"body":"Hello,\r\n\r\nI was very happy to find a simple serial command line interface for my Arduino sketches. Thank you for writing this!\r\n\r\nInitially I was unable to get \"cmd_line_ex1_hello.pde\" working until I figured out that I was terminating the command strings sent through the terminal program with \\r\\n instead of just \\r.\r\n\r\nI don't recall seeing any notes about using only \\r for string terminations in the comments, and I didn't realize that \\r\\n was corrupting the input buffer for every command sent after the first command sent. I found the problem while reviewing the \"switch (c)\" code of Cmd.cpp and verifying that your screen capture example showing the use of \"Carriage return\" terminations as see on flicker at:\r\n\r\n    https://www.flickr.com/photos/22874071@N05/10473274214/in/photostream/\r\n\r\nTo prevent an accidental \\r\\n from breaking the input routine, I added a filter to remove all incoming \\n characters. I don't know how often \\n might be a valid input character that is being incorrectly filtered out, but the likelihood of \\r\\n being sent accidentally as I move between different terminal programs highly likely. Someone needing the \\n character could just comment out the filtering case.\r\n\r\nI implemented the \\n filter by making a copy of the case '\\b' functionality for '\\n' instead of '\\b', and not echoing the \\n character back to the terminal. Below is the full modified switch statement with the additional case statement added.\r\n\r\nI am not familiar with pulling/pushing code changes through GitHub directly, so I opened this as an issue instead.\r\n\r\nRegards,\r\n\r\nDarrell\r\n\r\n  - - - -\r\n\r\n\r\n    switch (c)\r\n    {\r\n    case '\\r':\r\n        // terminate the msg and reset the msg ptr. then send\r\n        // it to the handler for processing.\r\n        *msg_ptr = '\\0';\r\n        Serial.print(\"\\r\\n\");\r\n        cmd_parse((char *)msg);\r\n        msg_ptr = msg;\r\n        break;\r\n    \r\n    case '\\b':\r\n        // backspace \r\n        Serial.print(c);\r\n        if (msg_ptr > msg)\r\n        {\r\n            msg_ptr--;\r\n        }\r\n        break;\r\n\r\n    case '\\n':    // This case added by d. on 6/5/2015. \r\n        // remove linefeeds so receiving \\r\\n won't corrupt buffer for next command \r\n        // Serial.print(c);     // Do not echo \\n back to terminal \r\n        if (msg_ptr > msg)\r\n        {\r\n            msg_ptr--;\r\n        }\r\n        break;\r\n    \r\n    default:\r\n        // normal character entered. add it to the buffer\r\n        Serial.print(c);\r\n        *msg_ptr++ = c;\r\n        break;\r\n    }\r\n\r\n"}}