isotp-c
isotp-c copied to clipboard
problem about send_bs_remain
when sending multi-frame, tp_poll handle remain packets. but in isotp_send_with_id function,send_bs_remain set to 0, causing tp_poll can not do sending. link->send_status will stay in ISOTP_SEND_STATUS_INPROGRESS. /* send multi-frame */ ret = isotp_send_first_frame(link, id); if (ISOTP_RET_OK == ret) { link->send_bs_remain = 0; link->send_st_min = 0; link->send_wtf_count = 0; link->send_timer_st = link->isotp_user_get_ms(); link->send_timer_bs = link->isotp_user_get_ms() + ISO_TP_DEFAULT_RESPONSE_TIMEOUT; link->send_protocol_result = ISOTP_PROTOCOL_RESULT_OK; link->send_status = ISOTP_SEND_STATUS_INPROGRESS; } .... void isotp_poll(IsoTpLink *link) { int ret;
/* only polling when operation in progress */
if (ISOTP_SEND_STATUS_INPROGRESS == link->send_status) {
/* continue send data */
if (/* send data if bs_remain is invalid or bs_remain large than zero */
**(ISOTP_INVALID_BS == link->send_bs_remain || link->send_bs_remain > 0)** &&
/* and if st_min is zero or go beyond interval time */
(0 == link->send_st_min || (0 != link->send_st_min && IsoTpTimeAfter(link->isotp_user_get_ms(), link->send_timer_st)))) {
ret = isotp_send_consecutive_frame(link);
......
When you initiate a send, then link status gets set to ISOTP_SEND_STATUS_INPROGRESS. This never changes unless it fails (ERROR) or completes (IDLE).
So not sure where you see a problem.
There is a check before:
if (ISOTP_SEND_STATUS_INPROGRESS == link->send_status) {
isotp_user_debug("Abort previous message, transmission in progress.\n");
return ISOTP_RET_INPROGRESS;
}