|
@@ -25,8 +25,6 @@ shellmatta_ymodem_packet_t shellmatta_ymodem_packet;
|
|
shellmatta_ymodem_datatype_t shellmatta_ymodem_current_data_type = YMODEM_NONE;
|
|
shellmatta_ymodem_datatype_t shellmatta_ymodem_current_data_type = YMODEM_NONE;
|
|
/* structure of ymodem callback functions */
|
|
/* structure of ymodem callback functions */
|
|
shellmatta_ymodem_callbacks_t shellmatta_ymodem_callbacks;
|
|
shellmatta_ymodem_callbacks_t shellmatta_ymodem_callbacks;
|
|
-/* flag to disable byte processing in ymodem */
|
|
|
|
-bool ymodem_is_enabled = true;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Initialise the ymodem prior to actually receiving data
|
|
* @brief Initialise the ymodem prior to actually receiving data
|
|
@@ -93,12 +91,6 @@ void shellmatta_ymodem_receive_packet(shellmatta_handle_t handle, uint8_t byteIn
|
|
static char fileSizeStr[7u]; /* hopefully no more bytes than a million will ever be transmitted */
|
|
static char fileSizeStr[7u]; /* hopefully no more bytes than a million will ever be transmitted */
|
|
shellmatta_ymodem_rcv_retcode_t recvRetCode;
|
|
shellmatta_ymodem_rcv_retcode_t recvRetCode;
|
|
|
|
|
|
- /* skip byte processing if ymodem is not enabled */
|
|
|
|
- if (!ymodem_is_enabled)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
recvRetCode = shellmatta_ymodem_receive_byte(handle, byteIn);
|
|
recvRetCode = shellmatta_ymodem_receive_byte(handle, byteIn);
|
|
switch (shellmatta_ymodem_get_state(handle))
|
|
switch (shellmatta_ymodem_get_state(handle))
|
|
{
|
|
{
|
|
@@ -121,7 +113,7 @@ void shellmatta_ymodem_receive_packet(shellmatta_handle_t handle, uint8_t byteIn
|
|
break;
|
|
break;
|
|
|
|
|
|
case YMODEM_HEADER: /* go here if the first body packet is to be expected */
|
|
case YMODEM_HEADER: /* go here if the first body packet is to be expected */
|
|
- if (recvRetCode == STX_RECEIVED || SOH_RECEIVED)
|
|
|
|
|
|
+ if (recvRetCode == STX_RECEIVED || recvRetCode == SOH_RECEIVED)
|
|
{
|
|
{
|
|
shellmatta_ymodem_byte_counter = 0u;
|
|
shellmatta_ymodem_byte_counter = 0u;
|
|
shellmatta_ymodem_set_state(handle, RECEIVE_PACKET);
|
|
shellmatta_ymodem_set_state(handle, RECEIVE_PACKET);
|
|
@@ -341,6 +333,34 @@ void shellmatta_ymodem_receive_packet(shellmatta_handle_t handle, uint8_t byteIn
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+shellmatta_retCode_t shellmatta_ymodem_processByte(shellmatta_handle_t handle, char data)
|
|
|
|
+{
|
|
|
|
+ shellmatta_instance_t *inst = (shellmatta_instance_t*)handle;
|
|
|
|
+ uint32_t i;
|
|
|
|
+
|
|
|
|
+ /** -# check if session is cancelled -accept only if ymodem is between packets */
|
|
|
|
+ if(('\x03' == data) && (inst->ymodemState == WAIT_FOR_START))
|
|
|
|
+ {
|
|
|
|
+ /** -# explicitly reset ymodem with cancel, if it was active */
|
|
|
|
+ shellmatta_ymodem_reset(handle, true);
|
|
|
|
+
|
|
|
|
+ utils_terminateInput(inst);
|
|
|
|
+
|
|
|
|
+ return SHELLMATTA_ERROR;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ shellmatta_ymodem_receive_packet(handle, data);
|
|
|
|
+
|
|
|
|
+ if ((0u == size) && (inst->ymodemState == WAIT_FOR_START))
|
|
|
|
+ {
|
|
|
|
+ /* send initial ymodem symbol to start transmission */
|
|
|
|
+ shellmatta_ymodem_control(handle, YMODEM_CRC);
|
|
|
|
+ }
|
|
|
|
+ return SHELLMATTA_OK;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @brief Gives a return code depending on symbol received at different states of the ymodem module
|
|
* @brief Gives a return code depending on symbol received at different states of the ymodem module
|
|
* @param[in, out] handle shellmatta handle of the instance
|
|
* @param[in, out] handle shellmatta handle of the instance
|
|
@@ -565,16 +585,6 @@ shellmatta_ymodem_datatype_t shellmatta_ymodem_get_current_datatype(void)
|
|
return shellmatta_ymodem_current_data_type;
|
|
return shellmatta_ymodem_current_data_type;
|
|
}
|
|
}
|
|
|
|
|
|
-void shellmatta_ymodem_enable(void)
|
|
|
|
-{
|
|
|
|
- ymodem_is_enabled = true;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-void shellmatta_ymodem_disable(void)
|
|
|
|
-{
|
|
|
|
- ymodem_is_enabled = false;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* @brief starts the ymodem receive module
|
|
* @brief starts the ymodem receive module
|
|
* @param[in] handle shellmatta instance handle
|
|
* @param[in] handle shellmatta instance handle
|
|
@@ -590,10 +600,6 @@ uint8_t shellmatta_ymodem( shellmatta_handle_t handle,
|
|
uint16_t* packetSize,
|
|
uint16_t* packetSize,
|
|
shellmatta_ymodem_callbacks_t callbacks)
|
|
shellmatta_ymodem_callbacks_t callbacks)
|
|
{
|
|
{
|
|
-#ifdef SHELLMATTA_TRANSPORT
|
|
|
|
- /* disable transport layer so control symbols won't be caught by it */
|
|
|
|
- ((shellmatta_instance_t*)handle)->transportEnabled = false;
|
|
|
|
-#endif
|
|
|
|
shellmatta_ymodem_init(handle, buffer, fileSize, packetSize, callbacks);
|
|
shellmatta_ymodem_init(handle, buffer, fileSize, packetSize, callbacks);
|
|
|
|
|
|
/* send initial ymodem symbol to start transmission */
|
|
/* send initial ymodem symbol to start transmission */
|
|
@@ -613,18 +619,6 @@ void shellmatta_ymodem_end(shellmatta_handle_t handle, bool doCancel)
|
|
utils_clearInput((shellmatta_instance_t*)handle);
|
|
utils_clearInput((shellmatta_instance_t*)handle);
|
|
}
|
|
}
|
|
|
|
|
|
-void shellmatta_ymodem_set_enable(bool doEnable)
|
|
|
|
-{
|
|
|
|
- if (doEnable)
|
|
|
|
- {
|
|
|
|
- shellmatta_ymodem_enable();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- shellmatta_ymodem_disable();
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
bool shellmatta_ymodem_is_active(void)
|
|
bool shellmatta_ymodem_is_active(void)
|
|
{
|
|
{
|
|
return shellmatta_ymodem_get_current_datatype() != YMODEM_NONE;
|
|
return shellmatta_ymodem_get_current_datatype() != YMODEM_NONE;
|