|
@@ -88,7 +88,7 @@ shellmatta_retCode_t processPacket(shellmatta_handle_t handle)
|
|
{
|
|
{
|
|
fileName = (char*)inst->ymodem.packet.packetData;
|
|
fileName = (char*)inst->ymodem.packet.packetData;
|
|
|
|
|
|
- ret = utils_shellAsciiToUInt32((char*)&inst->ymodem.packet.packetData[strlen(fileName)],
|
|
|
|
|
|
+ ret = utils_shellAsciiToUInt32((char*)&inst->ymodem.packet.packetData[strlen(fileName) + 1u],
|
|
&inst->ymodem.fileSize);
|
|
&inst->ymodem.fileSize);
|
|
|
|
|
|
/** -# pass filename and size to the callback */
|
|
/** -# pass filename and size to the callback */
|
|
@@ -97,9 +97,14 @@ shellmatta_retCode_t processPacket(shellmatta_handle_t handle)
|
|
else
|
|
else
|
|
{
|
|
{
|
|
/** -# calculate packet size - when it is the last packet this is limited by the file size */
|
|
/** -# calculate packet size - when it is the last packet this is limited by the file size */
|
|
- packetSize = SHELLMATTA_MAX((inst->ymodem.totalBytesReceived + inst->ymodem.packet.size),
|
|
|
|
- inst->ymodem.fileSize);
|
|
|
|
- packetSize = packetSize % inst->ymodem.packet.size;
|
|
|
|
|
|
+ if((inst->ymodem.totalBytesReceived + inst->ymodem.packet.size) > inst->ymodem.fileSize)
|
|
|
|
+ {
|
|
|
|
+ packetSize = inst->ymodem.fileSize % inst->ymodem.packet.size;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ packetSize = inst->ymodem.packet.size;
|
|
|
|
+ }
|
|
|
|
|
|
/** -# pass data to the application using the callback */
|
|
/** -# pass data to the application using the callback */
|
|
inst->ymodem.recvPacketCallback(inst->ymodem.packet.packetData, packetSize, inst->ymodem.packetCounter);
|
|
inst->ymodem.recvPacketCallback(inst->ymodem.packet.packetData, packetSize, inst->ymodem.packetCounter);
|
|
@@ -133,12 +138,17 @@ static shellmatta_retCode_t ymodem_stateMachine(shellmatta_handle_t handle, uint
|
|
inst->ymodem.state = SHELLMATTA_YMODEM_RECEIVE_HEADER;
|
|
inst->ymodem.state = SHELLMATTA_YMODEM_RECEIVE_HEADER;
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
+ case YMODEM_EOT:
|
|
inst->ymodem.transmissionCompleteCallback();
|
|
inst->ymodem.transmissionCompleteCallback();
|
|
|
|
|
|
|
|
+ // todo check for a complete telegram having been received
|
|
|
|
+ // ...add a wait state to answer some more EOTs after time
|
|
|
|
+
|
|
/** -# ACK the successful file reception */
|
|
/** -# ACK the successful file reception */
|
|
shellmatta_ymodem_control(handle, YMODEM_ACK);
|
|
shellmatta_ymodem_control(handle, YMODEM_ACK);
|
|
shellmatta_ymodem_control(handle, YMODEM_CRC);
|
|
shellmatta_ymodem_control(handle, YMODEM_CRC);
|
|
inst->ymodem.state = SHELLMATTA_YMODEM_INACTIVE;
|
|
inst->ymodem.state = SHELLMATTA_YMODEM_INACTIVE;
|
|
|
|
+ (void)utils_terminateInput(inst);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
/** -# ignore unexpected characters on start */
|
|
/** -# ignore unexpected characters on start */
|
|
@@ -203,8 +213,6 @@ static shellmatta_retCode_t ymodem_stateMachine(shellmatta_handle_t handle, uint
|
|
ret = processPacket(handle);
|
|
ret = processPacket(handle);
|
|
if(SHELLMATTA_OK == ret)
|
|
if(SHELLMATTA_OK == ret)
|
|
{
|
|
{
|
|
- inst->ymodem.packetCounter ++;
|
|
|
|
-
|
|
|
|
if(0u != inst->ymodem.packetCounter)
|
|
if(0u != inst->ymodem.packetCounter)
|
|
{
|
|
{
|
|
/** -# Calculate the total bytes received */
|
|
/** -# Calculate the total bytes received */
|
|
@@ -220,6 +228,7 @@ static shellmatta_retCode_t ymodem_stateMachine(shellmatta_handle_t handle, uint
|
|
shellmatta_ymodem_control(handle, YMODEM_CRC);
|
|
shellmatta_ymodem_control(handle, YMODEM_CRC);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ inst->ymodem.packetCounter ++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|