From 3801ffdec5030a0fed95c516d8b04191632b0034 Mon Sep 17 00:00:00 2001 From: narspt Date: Sat, 2 Apr 2022 22:13:07 +0100 Subject: [PATCH] cleanly print out ambe model and version instead of raw printing whole ambe control packet reply, including non-printable chars, field identifiers and even parity byte... --- ambed/cusb3xxxinterface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ambed/cusb3xxxinterface.cpp b/ambed/cusb3xxxinterface.cpp index c15801c..1ebe3f1 100644 --- a/ambed/cusb3xxxinterface.cpp +++ b/ambed/cusb3xxxinterface.cpp @@ -355,7 +355,12 @@ bool CUsb3xxxInterface::ReadDeviceVersion(void) ok = (len != 0); //we succeed in reading a packet, print it out std::cout << "ReadDeviceVersion : "; - for ( i = 4; i < len+4 ; i++ ) + for ( i = 5; (i < len+4) && (rxpacket[i] != 0x00); i++ ) + { + std::cout << (char)(rxpacket[i] & 0x00ff); + } + std::cout << " "; + for ( i = i+2; (i < len+4) && (rxpacket[i] != 0x00); i++ ) { std::cout << (char)(rxpacket[i] & 0x00ff); }