Skip to content

Commit

Permalink
limeOEM: fix printing of serial number
Browse files Browse the repository at this point in the history
  • Loading branch information
rjonaitis committed Oct 10, 2024
1 parent 0a99ede commit 7fa5130
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions cli/limeOEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ int main(int argc, char** argv)
{
uint64_t serialNumber = device->GetDescriptor().serialNumber;
cerr << "Board serial number: " << serialNumber << " (";
stringstream ss;
ss << std::hex << std::setw(2) << std::setfill('0');
for (size_t i = 0; i < sizeof(serialNumber); ++i)
cerr << hex << "0x" << std::setw(2) << std::setfill('0') << ((serialNumber >> 8 * i) & 0xFF) << " ";
cerr << ")" << endl;
ss << "0x" << ((serialNumber >> 8 * i) & 0xFF) << " ";
cerr << ss.str() << ")" << endl;

PrintOEMTestReporter reporter(serialNumber, reportFilename);
reporter.ReportColumn("S/N", std::to_string(serialNumber));
Expand Down
7 changes: 4 additions & 3 deletions src/protocols/LMS64CProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,9 @@ OpStatus WriteSerialNumber(ISerialPort& port, const std::vector<uint8_t>& serial
bytes.resize(currentSerial.size());
std::stringstream ss;
ss << "Padding serial number to:";
ss << std::hex << std::setw(2) << std::setfill('0');
for (size_t i = 0; i < bytes.size(); ++i)
ss << std::setw(2) << std::setfill('0') << std::hex << bytes[i] << " ";
ss << "0x" << static_cast<uint32_t>(bytes[i]) << " ";
lime::debug(ss.str());
}
}
Expand Down Expand Up @@ -933,9 +934,9 @@ OpStatus WriteSerialNumber(ISerialPort& port, const std::vector<uint8_t>& serial
return OpStatus::Error;

std::stringstream ss;
ss << "Serial number written:";
ss << "Serial number written:" << std::hex << std::setw(2) << std::setfill('0');
for (uint8_t b : bytes)
ss << std::hex << b << " ";
ss << "0x" << static_cast<uint32_t>(b) << " ";
lime::info(ss.str());
// wait for things to settle, otherwise reading serial immediately will return zeroes
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Expand Down

0 comments on commit 7fa5130

Please sign in to comment.