src/slcan_decode.c
/**
 * This decodes a number with an arbitrary number of digits up to 8.
 * The number is read as big endian.
 * 
 * @param buf    The buffer to use
 * @param length The number of digits to decode, max 8
 * 
 * @return The decoded number, unsigned
 */
This decodes a number with an arbitrary number of digits up to 8.
The number is read as big endian.

@param buf    The buffer to use
@param length The number of digits to decode, max 8

@return The decoded number, unsigned
This decodes a number with an arbitrary number of digits up to 8 . The number is read as big endian . @param buf The buffer to use @param length The number of digits to decode max 8 @return The decoded number unsigned
uint32_t decodeNumber(uint8_t *buf, uint8_t length) {
    uint32_t ret = 0;
    uint8_t i;
    if (buf != NULL) {
        length = (length > 8) ? 8 : length;
        for (i = 0; i < length; i++) {
            ret <<= 4;
            ret += decodeDigit(buf[i]) & 0xF;
        }
    }
    return ret;
}
uint32_t decodeNumber ( uint8_t * buf , uint8_t length ) { uint32_t ret = 0 ; uint8_t i ; if ( buf != NULL ) { length = ( length > 8 ) ? 8 : length ; for ( i = 0 ; i < length ; i ++ ) { ret <<= 4 ; ret += decodeDigit ( buf [ i ] ) & 0xF ; } } return ret ; }
This decodes a number with an arbitrary number of digits up to 8.
This decodes a number with an arbitrary number of digits up to 8 .