How to handle ADL_FCM_RET_OK_WAIT_RESUME when sending data?


#1

I’m sending data over UART1, but sometimes I have transmission errors: ADL_FCM_RET_OK_WAIT_RESUME. According to the manual the transmit buffer should be full, but I’m only sending small datablocks. Does anyone know how to handle in this situation? Do you have to wait on ADL_FCM_EVENT_RESUME and how long can it take?


#2

I’d like to know the answer to this one too if anyone is willing to volunteer a response :slight_smile:


#3

Hi,

it’s very simple: when adl_fcmSendData() returns ADL_FCM_RET_OK_WAIT_RESUME, you may not use the function again to send more data until you receive ADL_FCM_EVENT_MEM_RELEASE in the flow control handler function.

In this case you could buffer the data yourself and send it whenever you are allowed to send more…

for example you could do something like

static bool WaitResume = FALSE;
static ascii out_buffer[256] = { 0 };

void SendUART2( ascii *text )
{
  if ( WaitResume ) {
    // put text in your own buffer...
    if ( (wm_strlen(text)+wm_strlen(out_buffer)) < 255 )
      wm_strcat( out_buffer, text );
    else
      ... handle ERROR buffer overrun!
  } else {
    s8 result;
    if ( wm_strlen(out_buffer) > 0 ) {
      // there is buffered data... send it first!
      result = adl_fcmSendData( Handle, out_buffer, wm_strlen(out_buffer) );
      out_buffer[0] = 0;
      if ( result == ADL_FCM_RET_OK_WAIT_RESUME )  {
        WaitResume = TRUE;
        // put text in your own buffer...
        if ( (wm_strlen(text)+wm_strlen(out_buffer)) < 255 )
          wm_strcat( out_buffer, text );
        else
          ... handle ERROR buffer overrun!
        return;
      }
      result = adl_fcmSendData( Handle, text, wm_strlen(text) );
      if ( result == ADL_FCM_RET_OK_WAIT_RESUME )
        WaitResume = TRUE;
   }
}




bool fcmCtrlH( adl_fcmEvent_e event )
{
  switch( event )  {
    case ADL_FCM_EVENT_FLOW_OPENNED:
       ...
    case ADL_FCM_EVENT_V24_DATA_MODE:
       ...
    case ADL_FCM_EVENT_RESUME:
    {
       WaitResume = FALSE;
       SendUART2( "" );      // send nothing new but send buffer!!
       break;
    }
    case ADL_FCM_EVENT_MEM_RELEASE:
       ...
    default:
       ...
  }
  return TRUE;
}

Best Regards,
Jan