SPLat Logo

aComRx_fGetNum pp,fw [D>=29]

NOTICE: Our web site is being updated, but is currently experiencing extreme slowness due to host issues. Please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map
SPLat will be shut down for the Christmas Holiday season from Friday 20 December 2024 through Tuesday 7 January 2025. We will check emails periodically and will continue to process orders but at a slower pace. Santa hat

aComRx_fGetNum pp,fw [D>=29]

Return a decimal number from the head of the Rx buffer for the serial port at address pp. Skip any leading spaces. Process leading + or - sign if present. Terminate on anything thereafter that's not a decimal digit or decimal point, or after processing fw characters in total (including spaces, sign and decimal point). Consume the characters used but not the terminating character. Result in W, NaN if nothing there. R register signals outcome. 0 = OK, 1 = no valid decimal number present.

Notes:

  1. This differs from the same instruction without the leading 'a' in that it explicitly nominates a serial port address (pp) rather than the default serial port.
  2. This instruction will only process characters that have already been received. You should therefore ensure that either a known terminating character, or the required number of characters, have been received before attempting to execute this instruction.
  3. The character count fw includes leading spaces, signs and decimal point.
  4. The only characters removed from the buffer are leading spaces plus the characters that form the number. Hence, if a terminating character is encountered before fw characters are used, less than fw characters will be removed from the buffer.
  5. Conversion will end on the first unexpected character, including a trailing space, a second sign character or a second decimal point. This overrides the field width.
  6. The valid range for fw is 1 to 255. fw = 255 disables character counting.
  7. Anything more than 7 digits of input is meaningless, as the floating point number representation is only accurate to 6 or 7 decimal places. Excess digits will be nevertheless be consumed, up to the limits of fw.

Can only exist on boards that have an uncommitted serial port other than the programming port.

See also COMRx_GetHex, COMRx_BufLen, COMRx_FindXInBuf

Examples

The following shows the result of the instruction ComRx_fGetNum 8 for various receive buffer contents.

Receive buffer contents before (Shown as ASCII (printable) characters. Result returned in W Receive buffer contents after conversion Comment

123.456xxxxxxxx

23.456

xxxxxxxx

 

123.456xxxx

123

456xxxx

Leading spaces are counted in the field width. The decimal point "makes it",

-123.456xxxxxxx

-123.456

xxxxxxx

All good, got it all

-123.456xxxxxx

-123.45  

The last digit is excluded, because the field width of 8 terminates conversion. Furthermore, a subsequent conversion (with I as-is) would return 6.

-12.3.456xxxxx

-12.3

.456xxxxx

The second decimal point terminates conversion. If the same instruction were executed again (with I as-is), it would return 0.456

Dialect exclusions: Not available in dialects before 29