Re: serial2input
Posted: Sun Feb 26, 2017 1:59 pm
I was referring to online serial port docs which says that full serial2 is available, but it seems that serial2.read.int() returns an error so apparently is not supported. Doesn't prevent you from trying to read serial2 into a pre-declared int variable though (without $), it will either be read as numeric or not.
It all depends on what data is being sent to serial2, and what you are trying to accomplish with it.
If you have a look at the ascii table that mmiscool has helpfully included at the bottom of the online docs, you'll see that all the numbers from 0 to 31 are translated as control codes (which do not display), eg: number 13 causes a carraige return when 'printed' to screen.
You'll notice that ascii 0 (zero) is interpreted as NULL, whereas the printable ascii character "0" is represented by the decimal number 48.
So you can see that if you want to display incoming numeric digits (eg: for dev and debugging purposes) you can add 48 to each serial digit to turn it into it's printable ascii equivalent - but bear in mind that non-separated consecutive digits (such as 32) would originally comprise a multiple digit decimal (or hex) number.
It all depends on what data is being sent to serial2, and what you are trying to accomplish with it.
If you have a look at the ascii table that mmiscool has helpfully included at the bottom of the online docs, you'll see that all the numbers from 0 to 31 are translated as control codes (which do not display), eg: number 13 causes a carraige return when 'printed' to screen.
You'll notice that ascii 0 (zero) is interpreted as NULL, whereas the printable ascii character "0" is represented by the decimal number 48.
So you can see that if you want to display incoming numeric digits (eg: for dev and debugging purposes) you can add 48 to each serial digit to turn it into it's printable ascii equivalent - but bear in mind that non-separated consecutive digits (such as 32) would originally comprise a multiple digit decimal (or hex) number.