@@ -795,6 +795,10 @@ static void cp_phy_state_wait(struct osdp_pd *pd, uint32_t wait_ms)
795795 pd -> phy_state = OSDP_CP_PHY_STATE_WAIT ;
796796}
797797
798+ static int cp_calculate_transmit_time (struct osdp_pd * pd ){
799+ return (pd -> packet_buf_len * 10000U + pd -> baud_rate - 1 ) / pd -> baud_rate ;
800+ }
801+
798802static int cp_phy_state_update (struct osdp_pd * pd )
799803{
800804 int rc , ret = OSDP_CP_ERR_DEFER ;
@@ -830,6 +834,7 @@ static int cp_phy_state_update(struct osdp_pd *pd)
830834 pd -> reply_id = REPLY_INVALID ;
831835 pd -> phy_state = OSDP_CP_PHY_STATE_REPLY_WAIT ;
832836 pd -> phy_tstamp = osdp_millis_now ();
837+ pd -> resp_expected = pd -> phy_tstamp + OSDP_RESP_TOUT_MS + cp_calculate_transmit_time (pd );
833838 break ;
834839 case OSDP_CP_PHY_STATE_REPLY_WAIT :
835840 rc = cp_process_reply (pd );
@@ -856,7 +861,7 @@ static int cp_phy_state_update(struct osdp_pd *pd)
856861 cp_phy_state_wait (pd , OSDP_CMD_RETRY_WAIT_MS );
857862 return OSDP_CP_ERR_DEFER ;
858863 }
859- if (osdp_millis_since (pd -> phy_tstamp ) > OSDP_RESP_TOUT_MS ) {
864+ if (osdp_millis_since (pd -> phy_tstamp ) > pd -> resp_expected ) {
860865 if (pd -> phy_retry_count < OSDP_CMD_MAX_RETRIES ) {
861866 pd -> phy_retry_count += 1 ;
862867 LOG_WRN ("No response in 200ms; probing (%d)" ,
0 commit comments