This commit is contained in:
2021-09-11 20:37:15 +02:00
parent 1021893844
commit 2a529f224a
3 changed files with 7 additions and 5 deletions

3
TODO
View File

@@ -1 +1,2 @@
Code 0x41 A1 stage lookup in RS PRO problem Pravdepodobne nejaky bug v TimeoutSerial read v tom ze cita s oneskorenim 1
Length 1 a potom este pise TimeoutSerial

View File

@@ -91,10 +91,11 @@ void TimeoutSerial::writeString(const std::string& s)
size_t TimeoutSerial::read(char *data, size_t size) 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 if(readData.size()>0)//If there is some data from a previous read
{ {
istream is(&readData); 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); is.read(data,toRead);
data+=toRead; data+=toRead;
size-=toRead; size-=toRead;
@@ -113,7 +114,7 @@ size_t TimeoutSerial::read(char *data, size_t size)
asio::placeholders::error)); asio::placeholders::error));
result=resultInProgress; result=resultInProgress;
bytesTransferred=0; bytesTransferred=toRead;
for(;;) for(;;)
{ {
io.run_one(); io.run_one();
@@ -238,7 +239,7 @@ void TimeoutSerial::readCompleted(const boost::system::error_code& error,
if(!error || error.value() == 158) if(!error || error.value() == 158)
{ {
result=resultSuccess; result=resultSuccess;
this->bytesTransferred=bytesTransferred; this->bytesTransferred+=bytesTransferred;
return; return;
} }

View File

@@ -270,7 +270,7 @@ Ymodem::Code Ymodem::receivePacket()
{ {
uint32_t len = read(&(rxBuffer[1]), YMODEM_PACKET_SIZE + YMODEM_PACKET_OVERHEAD - 1); 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)) if(len < (YMODEM_PACKET_SIZE + YMODEM_PACKET_OVERHEAD - 1))
{ {