[FL-2219] VCP: fix Tx data freeze on sending 64 bytes packets #992
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		
							parent
							
								
									939998a8c8
								
							
						
					
					
						commit
						be500993a3
					
				| @ -77,6 +77,7 @@ static int32_t vcp_worker(void* context) { | |||||||
|     bool enabled = true; |     bool enabled = true; | ||||||
|     bool tx_idle = false; |     bool tx_idle = false; | ||||||
|     size_t missed_rx = 0; |     size_t missed_rx = 0; | ||||||
|  |     uint8_t last_tx_pkt_len = 0; | ||||||
| 
 | 
 | ||||||
|     furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb, NULL); |     furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb, NULL); | ||||||
| 
 | 
 | ||||||
| @ -184,8 +185,16 @@ static int32_t vcp_worker(void* context) { | |||||||
|             if(len > 0) { // Some data left in Tx buffer. Sending it now
 |             if(len > 0) { // Some data left in Tx buffer. Sending it now
 | ||||||
|                 tx_idle = false; |                 tx_idle = false; | ||||||
|                 furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len); |                 furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len); | ||||||
|             } else { // There is nothing to send. Set flag to start next transfer instantly
 |                 last_tx_pkt_len = len; | ||||||
|                 tx_idle = true; |             } else { // There is nothing to send.
 | ||||||
|  |                 if(last_tx_pkt_len == 64) { | ||||||
|  |                     // Send extra zero-length packet if last packet len is 64 to indicate transfer end
 | ||||||
|  |                     furi_hal_cdc_send(VCP_IF_NUM, NULL, 0); | ||||||
|  |                 } else { | ||||||
|  |                     // Set flag to start next transfer instantly
 | ||||||
|  |                     tx_idle = true; | ||||||
|  |                 } | ||||||
|  |                 last_tx_pkt_len = 0; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -77,6 +77,7 @@ static int32_t vcp_worker(void* context) { | |||||||
|     bool enabled = true; |     bool enabled = true; | ||||||
|     bool tx_idle = false; |     bool tx_idle = false; | ||||||
|     size_t missed_rx = 0; |     size_t missed_rx = 0; | ||||||
|  |     uint8_t last_tx_pkt_len = 0; | ||||||
| 
 | 
 | ||||||
|     furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb, NULL); |     furi_hal_cdc_set_callbacks(VCP_IF_NUM, &cdc_cb, NULL); | ||||||
| 
 | 
 | ||||||
| @ -184,8 +185,16 @@ static int32_t vcp_worker(void* context) { | |||||||
|             if(len > 0) { // Some data left in Tx buffer. Sending it now
 |             if(len > 0) { // Some data left in Tx buffer. Sending it now
 | ||||||
|                 tx_idle = false; |                 tx_idle = false; | ||||||
|                 furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len); |                 furi_hal_cdc_send(VCP_IF_NUM, vcp->data_buffer, len); | ||||||
|             } else { // There is nothing to send. Set flag to start next transfer instantly
 |                 last_tx_pkt_len = len; | ||||||
|                 tx_idle = true; |             } else { // There is nothing to send.
 | ||||||
|  |                 if(last_tx_pkt_len == 64) { | ||||||
|  |                     // Send extra zero-length packet if last packet len is 64 to indicate transfer end
 | ||||||
|  |                     furi_hal_cdc_send(VCP_IF_NUM, NULL, 0); | ||||||
|  |                 } else { | ||||||
|  |                     // Set flag to start next transfer instantly
 | ||||||
|  |                     tx_idle = true; | ||||||
|  |                 } | ||||||
|  |                 last_tx_pkt_len = 0; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Nikolay Minaylov
						Nikolay Minaylov