File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
components/utilities/ymodem Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ static rt_err_t _rym_do_handshake(
125125 rt_size_t i ;
126126 rt_uint16_t recv_crc , cal_crc ;
127127 rt_size_t data_sz ;
128+ rt_tick_t tick ;
128129
129130 ctx -> stage = RYM_STAGE_ESTABLISHING ;
130131 /* send C every second, so the sender could know we are waiting for it. */
@@ -149,8 +150,17 @@ static rt_err_t _rym_do_handshake(
149150 return - RYM_ERR_TMO ;
150151 }
151152
152- i = _rym_read_data (ctx , data_sz - 1 );
153- if (i != (data_sz - 1 ))
153+ /* receive all data */
154+ i = 0 ;
155+ /* automatic exit after receiving specified length data, timeout: 100ms */
156+ tick = rt_tick_get ();
157+ while (rt_tick_get () <= (tick + rt_tick_from_millisecond (100 )) && i < (data_sz - 1 ))
158+ {
159+ i += _rym_read_data (ctx , data_sz - 1 );
160+ rt_thread_mdelay (5 );
161+ }
162+
163+ if (i != (data_sz - 1 ))
154164 return - RYM_ERR_DSZ ;
155165
156166 /* sanity check */
You can’t perform that action at this time.
0 commit comments