MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / _long_handle_second

Function _long_handle_second

components/utilities/rt-link/src/rtlink.c:482–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482static void _long_handle_second(struct rt_link_frame *receive_frame)
483{
484 static rt_uint8_t ack_mask = RT_LINK_ACK_MAX;
485 rt_size_t offset = 0; /* offset, count from 0 */
486
487 receive_frame->index = rt_link_check_seq(receive_frame->head.sequence, rt_link_scb->rx_record.rx_seq) - 1;
488 LOG_D("seq(%d), rxseq(%d), index(%d), total(%d), count(0x%x)"
489 , receive_frame->head.sequence
490 , rt_link_scb->rx_record.rx_seq
491 , receive_frame->index
492 , receive_frame->total
493 , rt_link_scb->rx_record.long_count);
494
495 if ((receive_frame->index > RT_LINK_FRAMES_MAX) || (rt_link_scb->rx_record.long_count & (0x01 << receive_frame->index)))
496 {
497 LOG_D("ERR:index %d, rx_seq %d", receive_frame->index, rt_link_scb->rx_record.rx_seq);
498 }
499 else if (rt_link_scb->rx_record.dataspace != RT_NULL)
500 {
501 rt_link_scb->rx_record.long_count |= (0x01 << receive_frame->index);
502 offset = RT_LINK_MAX_DATA_LENGTH * receive_frame->index;
503 rt_link_hw_copy(rt_link_scb->rx_record.dataspace + offset, receive_frame->real_data, receive_frame->data_len);
504
505 if (receive_frame->head.ack)
506 {
507 if (rt_link_utils_num1(rt_link_scb->rx_record.long_count) == rt_link_scb->rx_record.total)
508 {
509 rt_link_command_frame_send(receive_frame->head.service,
510 (rt_link_scb->rx_record.rx_seq + rt_link_scb->rx_record.total),
511 RT_LINK_CONFIRM_FRAME, RT_NULL);
512 }
513 else if ((rt_link_scb->rx_record.long_count & ack_mask) == ack_mask)
514 {
515 rt_link_command_frame_send(receive_frame->head.service,
516 (rt_link_scb->rx_record.rx_seq + rt_link_utils_num1(ack_mask)),
517 RT_LINK_CONFIRM_FRAME, RT_NULL);
518 ack_mask |= ack_mask << rt_link_utils_num1(RT_LINK_ACK_MAX);
519 }
520 }
521
522 /* receive a complete package */
523 if (rt_link_utils_num1(rt_link_scb->rx_record.long_count) == rt_link_scb->rx_record.total)
524 {
525 rt_timer_stop(&rt_link_scb->longframetimer);
526 rt_link_recv_finish(receive_frame->head.service, rt_link_scb->rx_record.dataspace, receive_frame->extend.parameter);
527
528 rt_enter_critical();
529 /* empty rx_record */
530 rt_link_scb->rx_record.rx_seq += rt_link_scb->rx_record.total;
531 rt_link_scb->rx_record.dataspace = RT_NULL;
532 rt_link_scb->rx_record.long_count = 0;
533 rt_link_scb->rx_record.total = 0;
534 ack_mask = RT_LINK_ACK_MAX;
535 rt_exit_critical();
536 }
537 else if (rt_link_hw_recv_len(rt_link_scb->rx_buffer) < (receive_frame->data_len % RT_LINK_MAX_DATA_LENGTH))
538 {
539 rt_tick_t timeout = RT_LINK_LONG_FRAME_TIMEOUT;

Callers 1

rt_link_long_handleFunction · 0.85

Calls 11

rt_link_check_seqFunction · 0.85
rt_link_hw_copyFunction · 0.85
rt_link_utils_num1Function · 0.85
rt_timer_stopFunction · 0.85
rt_link_recv_finishFunction · 0.85
rt_link_hw_recv_lenFunction · 0.85
rt_timer_controlFunction · 0.85
rt_timer_startFunction · 0.85
rt_enter_criticalFunction · 0.50
rt_exit_criticalFunction · 0.50

Tested by

no test coverage detected