tag:blogger.com,1999:blog-3346733573011815450.post351471103146776316..comments2024-02-05T11:04:03.439+01:00Comments on Linux for an engineer: Arduino: Read Instruction From SerialJMGhttp://www.blogger.com/profile/10119747138741258182noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-3346733573011815450.post-10622390988146758372015-10-27T20:11:16.759+01:002015-10-27T20:11:16.759+01:00Hello. Thanks for your comment, I have improved th...Hello. Thanks for your comment, I have improved the code to use only one string variable with a declared length and using a char array for the function done previously by "String readString".<br /><br />I've tested it and did not find any errors, but as this code will be part from a CNC machine that I'll publishing soon (open source), I would like to hear any comments about possible problems with this new version.<br /><br />Thanks in advance. JMGhttps://www.blogger.com/profile/10119747138741258182noreply@blogger.comtag:blogger.com,1999:blog-3346733573011815450.post-14970161313922202262015-10-24T13:31:50.387+02:002015-10-24T13:31:50.387+02:00Your code works for a very limited use, just as a ...Your code works for a very limited use, just as a (very bad) example. If you tried more commands, let's say around hundreds Arduino would run out of memory and reboot...<br />Proper way to do this is using char[] array as fixed length buffer, Google for Serial input basics topic on Arduino forum.<br />Main problem of your example is declaring String readString; and then using it as a buffer of unknown length. On a 2kb of available ram it's sure to cause problems. On a PC it's OK.<br />Serial input basics topic is a must read on Arduino forum if you want to use Serial for anything reliable...Unknownhttps://www.blogger.com/profile/10738049924400844454noreply@blogger.com