[Bugfix][T108] [bug-view-1476] solve the problem of abnormal printing
Only Configure: No
Affected branch: GSW_V1453
Affected module: oem
Self-test: yes
Doc Update: no
Change-Id: I22acaad93b3b4dc258f1d92284315f85c661f4b0
diff --git a/mbtk/test/libgsw_lib/gsw_oem_rw_test.c b/mbtk/test/libgsw_lib/gsw_oem_rw_test.c
index 723c0c6..07356c5 100755
--- a/mbtk/test/libgsw_lib/gsw_oem_rw_test.c
+++ b/mbtk/test/libgsw_lib/gsw_oem_rw_test.c
@@ -132,7 +132,22 @@
else
{
printf("Read %u bytes\n", read_len);
- printf("Read data: %s\n", read_buf);
+ if (read_buf != NULL) {
+ int pos = -1;
+ for (int i = 0; i < read_len; i++) {
+ unsigned char c = ((unsigned char*)read_buf)[i];
+ if (c < 32 || c > 126) {
+ pos = i;
+ ((unsigned char*)read_buf)[i] = '.';
+ break;
+ }
+ }
+ printf("Read data: %s\n", (char*)read_buf);
+ }
+ else
+ {
+ printf("Read data: \n");
+ }
}
free(read_buf);
return ret;