mirror of https://github.com/PentHertz/srsLTE.git
srsran_vec_sprint_hex returns number of written characters
This commit is contained in:
parent
3634e96c3e
commit
bcb91d6173
|
@ -123,16 +123,16 @@ SRSRAN_API void srsran_vec_u16_copy(uint16_t* dst, const uint16_t* src, uint32_t
|
|||
SRSRAN_API void srsran_vec_i16_copy(int16_t* dst, const int16_t* src, uint32_t len);
|
||||
|
||||
/* print vectors */
|
||||
SRSRAN_API void srsran_vec_fprint_c(FILE* stream, const cf_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_f(FILE* stream, const float* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_b(FILE* stream, const uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_bs(FILE* stream, const int8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_byte(FILE* stream, const uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_i(FILE* stream, const int* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_s(FILE* stream, const int16_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_hex(FILE* stream, uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_c(FILE* stream, const cf_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_f(FILE* stream, const float* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_b(FILE* stream, const uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_bs(FILE* stream, const int8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_byte(FILE* stream, const uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_i(FILE* stream, const int* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_s(FILE* stream, const int16_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_fprint_hex(FILE* stream, uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API uint32_t srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len);
|
||||
SRSRAN_API void srsran_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* x, const uint32_t len);
|
||||
|
||||
/* Saves/loads a vector to a file */
|
||||
SRSRAN_API void srsran_vec_save_file(char* filename, const void* buffer, const uint32_t len);
|
||||
|
|
|
@ -354,7 +354,7 @@ void srsran_vec_fprint_hex(FILE* stream, uint8_t* x, const uint32_t len)
|
|||
fprintf(stream, "];\n");
|
||||
}
|
||||
|
||||
void srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len)
|
||||
uint32_t srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, const uint32_t len)
|
||||
{
|
||||
uint32_t i, nbytes;
|
||||
uint8_t byte;
|
||||
|
@ -362,7 +362,7 @@ void srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, co
|
|||
// check that hex string fits in buffer (every byte takes 3 characters, plus brackets)
|
||||
if ((3 * (len / 8 + ((len % 8) ? 1 : 0))) + 2 >= max_str_len) {
|
||||
ERROR("Buffer too small for printing hex string (max_str_len=%d, payload_len=%d).", max_str_len, len);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int n = 0;
|
||||
|
@ -376,7 +376,10 @@ void srsran_vec_sprint_hex(char* str, const uint32_t max_str_len, uint8_t* x, co
|
|||
n += sprintf(&str[n], "%02x ", byte);
|
||||
}
|
||||
n += sprintf(&str[n], "]");
|
||||
str[n] = 0;
|
||||
str[max_str_len - 1] = 0;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void srsran_vec_sprint_bin(char* str, const uint32_t max_str_len, const uint8_t* x, const uint32_t len)
|
||||
|
|
Loading…
Reference in New Issue