From 7079e698481705c82c7aff58ea9c63469626af80 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 5 Dec 2018 21:02:36 +0100 Subject: add osmo_bcd2str() Add a standalone bcd-to-string conversion function with generic parameters. Add a regression test in utils_test.c. So far there is no single universal implementation that converts a BCD to a string. I could only find gsm48_mi_to_string(), which also interprets surrounding bytes, MI type and TMSI as non-BCD value. The idea is to use this function from gsm48_mi_to_string() and similar implementations in subsequent commits. Root cause: in osmo-msc, I want to have an alternative MI-to-string function for composing an FSM name, which needs the BCD part of gsm48_mi_to_string() but not the TMSI part. Change-Id: I86b09d37ceef33331c1a56046a5443127d6c6be0 --- include/osmocom/core/utils.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/osmocom') diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 0b54c880..04f2fb4b 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -49,6 +49,8 @@ char osmo_bcd2char(uint8_t bcd); /* only works for numbers in ascci */ uint8_t osmo_char2bcd(char c); +int osmo_bcd2str(char *dst, size_t dst_size, const uint8_t *bcd, int start_nibble, int end_nibble, bool allow_hex); + int osmo_hexparse(const char *str, uint8_t *b, int max_len); char *osmo_ubit_dump(const uint8_t *bits, unsigned int len); -- cgit v1.2.3