lancaster-university / microbit-samples

http://lancaster-university.github.io/microbit-docs
Other
114 stars 72 forks source link

Carriage return needed in serial samples #9

Closed Mickulty closed 7 years ago

Mickulty commented 7 years ago

With all the serial clients I've tested (Tera Term and PuTTY on Windows 10 as well as Screen on linux), the button press sample code has an issue where each new line output to serial starts at the same point the last one ended - it seems it's missing a carriage return (\r) at the end of every line. I understand this isn't always necessary depending on the terminal, but since it does appear to be necessary with both the windows clients recommended on the micro:bit website the sample code should probably be changed to work normally with them.

jamesadevine commented 7 years ago

@Mickulty I think this should align to whatever the most widely adopted standard is.

My understanding was that \n was widely adopted on Windows, however that was incorrect, \r\n is the standard on Windows due to MS-DOS compatibility. Unix deviated from the usage \r\n and instead adopted \n.

If the majority of terminals don't recognise the \n character (especially those recommended on the microbit website) to mean \r\n, then these samples should be changed.

@finneyj thoughts?

finneyj commented 7 years ago

hi @Mickulty @jamesadevine

I think \r\n is a good suggestion. \r\n should work on all terminals, and \n on some... hence going with \r\n will give the best user experience. I think we update our samples repo accordingly, the next time we have a mo. :-)