Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transmit Stage Finishing流程中缺少了对第二次EOT消息的ACK响应的处理流程 #2

Open
shenyuanxiaolong opened this issue Nov 4, 2021 · 1 comment

Comments

@shenyuanxiaolong
Copy link

如题

@shenyuanxiaolong
Copy link
Author

`void Ymodem::transmitStageFinishing()
{
switch (receivePacket())
{
case CodeNak:
{
timeCount = 0;
errorCount = 0;
dataCount = 0;
code = CodeNone;
stage = StageFinishing;
txBuffer[0] = CodeEot;
txLength = 1;
write(txBuffer, txLength);

  break;
}

case CodeC:
{
  memset(&(txBuffer[YMODEM_PACKET_HEADER]), NULL, YMODEM_PACKET_SIZE);
  uint16_t crc = crc16(&(txBuffer[YMODEM_PACKET_HEADER]), YMODEM_PACKET_SIZE);

  timeCount                                                 = 0;
  errorCount                                                = 0;
  dataCount                                                 = 0;
  code                                                      = CodeNone;
  stage                                                     = StageFinished;
  txBuffer[0]                                               = CodeSoh;
  txBuffer[1]                                               = 0x00;
  txBuffer[2]                                               = 0xFF;
  txBuffer[YMODEM_PACKET_SIZE + YMODEM_PACKET_OVERHEAD - 2] = static_cast<uint8_t>(crc >> 8);
  txBuffer[YMODEM_PACKET_SIZE + YMODEM_PACKET_OVERHEAD - 1] = static_cast<uint8_t>(crc >> 0);
  txLength                                                  = YMODEM_PACKET_SIZE + YMODEM_PACKET_OVERHEAD;
  write(txBuffer, txLength);

  break;
}

case CodeAck:  
{
  timeCount  = 0;
  errorCount = 0;
  dataCount  = 0;
  code       = CodeNone;
  stage      = StageFinishing;
  //callback(StatusFinish, nullptr, nullptr);
  break;
}

case CodeA1:
case CodeA2:
case CodeCan:
{
  timeCount  = 0;
  errorCount = 0;
  dataCount  = 0;
  code       = CodeNone;
  stage      = StageNone;
  callback(StatusAbort, nullptr, nullptr);

  break;
}

default:
{
  timeCount++;

  if ((timeCount / (timeDivide + 1)) > timeMax)
  {
    timeCount  = 0;
    errorCount = 0;
    dataCount  = 0;
    code       = CodeNone;
    stage      = StageNone;

    for (txLength = 0; txLength < YMODEM_CODE_CAN_NUMBER; txLength++)
    {
      txBuffer[txLength] = CodeCan;
    }

    write(txBuffer, txLength);
    callback(StatusError, nullptr, nullptr);
  }
  else if ((timeCount % (timeDivide + 1)) == 0)
  {
    write(txBuffer, txLength);
  }
}

}
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant