Hi all, I have an application where I connect a TCP socket to UART1 (i.e. tunnel data). I manage to subscribe to the port once etc, but when I unsubscribed (after switching to AT mode and receiving ADL_FCM_EVENT_V24_AT_MODE message) I never receive the ADL_FCM_EVENT_FLOW_CLOSED event?
So next time I want to open the UART I notice that my FCM never closed properly. However when I try and unsubscribe again I get a -5 result which means ADL_RET_ERR_NOT_SUBSCRIBED.
Below is a snapshot of my code. Does anyone have any ideas why I would not be receiving this message?
bool serial1FcmCtrlHandler(adl_fcmEvent_e event)
{
//trace(2,"SOCKET: serial1FcmCtrlHandler %d", event);
switch(event)
{
case ADL_FCM_EVENT_FLOW_OPENNED:
serial_state.serialState = SERIAL_SUBSCRIBED;
break;
case ADL_FCM_EVENT_FLOW_CLOSED:
trace(2,"UART: ADL_FCM_EVENT_FLOW_CLOSED.");
serial_state.serialState = SERIAL_UNSUBSCRIBED;
serial_state.serial1FcmHandle = -1;
break;
case ADL_FCM_EVENT_V24_DATA_MODE:
trace(2,"UART: Flow in Data Mode");
/* sending data to the external application via V24 serial link */
if (serial_state.serial1FcmHandle != -1)
{
trace(2,"UART: Serial port opened.");
//serial1SendData(11, "Opened\n");
serial_state.serialState = SERIAL_DATAMODE;
Server_SerialTunnel_KickLoop();
}
else
{
trace(2,"UART: Serial port closed, cannot send data.");
serial_state.ResetServer = TRUE;
Server_SerialTunnel_KickLoop();
}
break;
case ADL_FCM_EVENT_V24_AT_MODE:
trace(2,"UART: ADL_FCM_EVENT_V24_AT_MODE");
//adl_fcmReleaseCredits( serial_state.serial1FcmHandle, 0XFF );
s8 result = adl_fcmUnsubscribe(serial_state.serial1FcmHandle);
if (result != OK)
{
trace(2, "SERIAL: Unsubscribe failed. %d . Forcing close.", result);
serial_state.serialState = SERIAL_UNSUBSCRIBED;
serial_state.serial1FcmHandle = -1;
}
else
serial_state.serialState = SERIAL_UNSUBSCRIBING;
break;
//other cases removed as irrelevant (just tracing event)
default:
trace(2, "UART: serial1FcmCtrlHandler Unhandled event: %d", event);
}
return TRUE;
}
Thanks,
Karl