X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Fio%2Frecord.cpp;h=97e601549428b26a4de512e3deba1e7d711a2926;hb=eac5817fe5ed5052599bbfb1ab3f6ade426010d0;hp=1332a0ffce437625691db71a656ea535aac8e38c;hpb=90a79f28e095c7e368971ee5408ba8a10e0043c9;p=cassiopeia.git diff --git a/src/io/record.cpp b/src/io/record.cpp index 1332a0f..97e6015 100644 --- a/src/io/record.cpp +++ b/src/io/record.cpp @@ -25,6 +25,12 @@ std::string toHexAndChecksum( const std::string& src ) { } void sendCommand( RecordHeader& head, const std::string& data, std::shared_ptr bio ) { + std::stringstream ss; + ss << data.size(); + logger::debugf( "Record payload length: %s", ss.str() ); + if(data.size() > 0xFFFF){ + logger::warn( "Data too big, need chunking" ); + } head.payloadLength = data.size(); std::string s; s += head.packToString(); @@ -79,7 +85,13 @@ std::string parseCommand( RecordHeader& head, const std::string& input) { uint32_t expectedTotalLength = ( RECORD_HEADER_SIZE + len + 1 /*checksum*/ ) * 2 + 2; std::string data = str.substr( RECORD_HEADER_SIZE, str.size() - RECORD_HEADER_SIZE ); - if( checksum != -1 || expectedTotalLength != input.size() || error || dlen < RECORD_HEADER_SIZE ) { + if( expectedTotalLength != input.size() ) { + std::stringstream ss; + ss << "Expected: " << expectedTotalLength << ", Got: " << input.size(); + logger::error( ss.str() ); + throw "Error, invalid length"; + } + if( checksum != -1 || error || dlen < RECORD_HEADER_SIZE ) { throw "Error, invalid checksum"; }