diff --git a/TODO b/TODO index 4d3a681..1c8e784 100644 --- a/TODO +++ b/TODO @@ -1 +1,2 @@ -Code 0x41 A1 stage lookup in RS PRO problem \ No newline at end of file +Pravdepodobne nejaky bug v TimeoutSerial read v tom ze cita s oneskorenim 1 +Length 1 a potom este pise TimeoutSerial \ No newline at end of file diff --git a/TimeoutSerial.cpp b/TimeoutSerial.cpp index 4bc1cd1..44f725a 100755 --- a/TimeoutSerial.cpp +++ b/TimeoutSerial.cpp @@ -91,10 +91,11 @@ void TimeoutSerial::writeString(const std::string& s) size_t TimeoutSerial::read(char *data, size_t size) { + size_t toRead = 0; if(readData.size()>0)//If there is some data from a previous read { istream is(&readData); - size_t toRead=min(readData.size(),size);//How many bytes to read? + toRead=min(readData.size(),size);//How many bytes to read? is.read(data,toRead); data+=toRead; size-=toRead; @@ -113,7 +114,7 @@ size_t TimeoutSerial::read(char *data, size_t size) asio::placeholders::error)); result=resultInProgress; - bytesTransferred=0; + bytesTransferred=toRead; for(;;) { io.run_one(); @@ -238,7 +239,7 @@ void TimeoutSerial::readCompleted(const boost::system::error_code& error, if(!error || error.value() == 158) { result=resultSuccess; - this->bytesTransferred=bytesTransferred; + this->bytesTransferred+=bytesTransferred; return; } diff --git a/Ymodem.cpp b/Ymodem.cpp index 0b464bf..d9603e7 100644 --- a/Ymodem.cpp +++ b/Ymodem.cpp @@ -270,7 +270,7 @@ Ymodem::Code Ymodem::receivePacket() { uint32_t len = read(&(rxBuffer[1]), YMODEM_PACKET_SIZE + YMODEM_PACKET_OVERHEAD - 1); - BOOST_LOG_TRIVIAL(debug) << "Len = " << len; + BOOST_LOG_TRIVIAL(debug) << "Len = " << len << " Start = " << rxBuffer[1]; if(len < (YMODEM_PACKET_SIZE + YMODEM_PACKET_OVERHEAD - 1)) {