From 3dd77909d3a571c2d02187e2656fe26d5265b51a Mon Sep 17 00:00:00 2001 From: Ron Eldor Date: Mon, 3 Jun 2019 16:39:59 +0300 Subject: [PATCH] Refactor get_byte function Change implementation of `get_byte()` to call `unhexify()`. --- tests/suites/target_test.function | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/tests/suites/target_test.function b/tests/suites/target_test.function index 35255c9d6..596730c46 100644 --- a/tests/suites/target_test.function +++ b/tests/suites/target_test.function @@ -69,28 +69,14 @@ int verify_dependencies( uint8_t count, uint8_t * dep_p ) uint8_t receive_byte() { uint8_t byte; - uint8_t c; + uint8_t c[3]; + char *endptr; + c[0] = greentea_getc(); + c[1] = greentea_getc(); + c[2] = '\0'; - c = greentea_getc(); - if( c >= '0' && c <= '9' ) - c -= '0'; - else if( c >= 'a' && c <= 'f' ) - c = ( c -'a' ) + 10; - else if( c >= 'A' && c <= 'F' ) - c = ( c - 'A' ) + 10; - - byte = c * 0x10; - - c = greentea_getc(); - if( c >= '0' && c <= '9' ) - c -= '0'; - else if( c >= 'a' && c <= 'f' ) - c = ( c -'a' ) + 10; - else if( c >= 'A' && c <= 'F' ) - c = ( c - 'A' ) + 10; - - byte += c ; - return( byte); + assert( unhexify( &byte, &c ) != 2 ); + return( byte ); } /**