icom-wlan-node
Version:
Icom WLAN (CI‑V, audio) protocol implementation for Node.js/TypeScript.
37 lines (36 loc) • 1.16 kB
TypeScript
/**
* BCD (Binary Coded Decimal) parsing utilities
* Based on FT8CN's IcomRigConstant.java twoByteBcdToInt()
*/
/**
* Parse a two-byte BCD encoded value to integer
*
* BCD format encodes decimal digits as nibbles (4-bit values):
* - Byte 0: thousands (high nibble) + hundreds (low nibble)
* - Byte 1: tens (high nibble) + ones (low nibble)
*
* @param data - Buffer containing at least 2 bytes of BCD data
* @returns Parsed integer value, or 0 if data is invalid
*
* @example
* // Buffer [0x12, 0x34] represents 1234
* const value = parseTwoByteBcd(Buffer.from([0x12, 0x34]));
* console.log(value); // 1234
*
* @example
* // Buffer [0x02, 0x40] represents 240 (SWR 2.40)
* const swr = parseTwoByteBcd(Buffer.from([0x02, 0x40]));
* console.log(swr / 100); // 2.40
*/
export declare function parseTwoByteBcd(data: Buffer): number;
/**
* Convert integer to two-byte BCD format
*
* @param value - Integer value (0-9999)
* @returns Buffer containing 2 bytes of BCD data
*
* @example
* const bcd = intToTwoByteBcd(1234);
* console.log(bcd); // Buffer [0x12, 0x34]
*/
export declare function intToTwoByteBcd(value: number): Buffer;