Want to Send data to USB with no result

Hi all!!, i need to send data to USB with no result. My code is this:

.........
//in main function
handle_envio_uart=adl_fcmSubscribe(ADL_PORT_USB,(adl_fcmCtrlHdlr_f)CtrlHandler,(adl_fcmDataHdlr_f)DataHandler);
	if(handle_envio_uart>0)
	TRACE((1,"[adl_main]:adl_fcmSubscribe OK"));
adl_tmrSubscribe(FALSE,100, ADL_TMR_TYPE_100MS,(adl_tmrHandler_t)Envio_UART); //el timer salta cada 1 segundo
.......
.......
/*Funtion handler */
bool CtrlHandler (adl_fcmEvent_e event)
{
switch(event)
{

case ADL_FCM_EVENT_FLOW_OPENNED:
TRACE((5,"[CtrlHandler]:ADL_FCM_EVENT_FLOW_OPENNED"));
puerto_abierto=TRUE;
return TRUE;

break;

case ADL_FCM_EVENT_FLOW_CLOSED:
TRACE((5,"[CtrlHandler]:ADL_FCM_EVENT_FLOW_CLOSED"));
puerto_abierto=FALSE;
return TRUE;

break;

case ADL_FCM_EVENT_MEM_RELEASE:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_MEM_RELEASE"));
return TRUE;

break;

case ADL_FCM_EVENT_RESUME:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_RESUME"));
return TRUE;

break;

case ADL_FCM_EVENT_V24_AT_MODE:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_V24_AT_MODE"));
return TRUE;

break;

case ADL_FCM_EVENT_V24_AT_MODE_EXT:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_V24_AT_MODE_EXT"));
return TRUE;

break;

case ADL_FCM_EVENT_V24_AT_MODE_FROM_CALL:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_V24_AT_MODE_FROM_CALL"));
return TRUE;

break;

case ADL_FCM_EVENT_V24_DATA_MODE:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_V24_DATA_MODE"));
return TRUE;

break;

case ADL_FCM_EVENT_V24_DATA_MODE_EXT:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_FLOW_OPENNED"));
return TRUE;

break;

case ADL_FCM_EVENT_V24_DATA_MODE_FROM_CALL:
TRACE((1,"[CtrlHandler]:ADL_FCM_EVENT_V24_DATA_MODE_FROM_CALL"));
return TRUE;

break;

return FALSE;
  }

}
.................
.................
/*Sending function*/

void Envio_UART(u8 TimerId)
	{
		u8 Data=12;
		s8 resultado;
		if(puerto_abierto==TRUE)
		{
		//TRACE (( 1, "[Envio_UART]:Envio Dato" ));
		resultado=adl_fcmSendData(handle_envio_uart,&Data,sizeof(Data)); //Here i send the data
		TRACE (( 5, "valor de resutado: %d",resultado ));
		switch(resultado)
			{
			case OK:
					{
					TRACE (( 1, "[Envio_UART]:OK " ));
					break;
					}


			case ADL_RET_ERR_PARAM:
					{
					TRACE (( 1, "[Envio_UART]:ADL_RET_ERR_PARAM" ));

					break;
					}


			case ADL_RET_ERR_BAD_HDL:
					{
					TRACE (( 1, "[Envio_UART]:ADL_RET_ERR_BAD_HDL" ));

					break;
					}


			case ADL_RET_ERR_SERVICE_LOCKED:
					{
					TRACE (( 1, "[Envio_UART]:ADL_RET_ERR_SERVICE_LOCKED" ));
					break;
					}

				}
	
			}
	adl_tmrSubscribe(FALSE,100, ADL_TMR_TYPE_100MS,(adl_tmrHandler_t)Envio_UART); 
	}

The adl_fcmSendData returns “-8”, wich is not explained in the pdf. Does anyone knows what i missing here?.
Thanks for advance!

Have you enabled the USB?

See: AT+WMFM

Yes, it is - see the section titled, “Error Codes” at the end of the ADL User Guide!

Thanks for your reply, yes!, i sent at+WMFM=0,1,3. In fact, i use the USB as an alternative shell. I dont know why im recieveng the -8 error wich is “BAD_STATE”. Also, the adl_fcmSubscribe returns 0 wich is an aceptable value.

I really dont know what can i do. Thanks for advance.

As the name tells you, you receive “BAD_STATE” because the Flow is not in the correct state for the operation that you are attempting!

Re-read the FCM documentation carefully - noting that a UART flow, once subscribed, can be in one of two states

Also, look at the sample applications that use FCM on the UARTs…

You are the man!!!. Its working!!!.

I missed one step before!. I need to use the adl_fcmSwitchV24State funtion to set the Data Mode. So, one more time, youre right.

Thank u so much!!!.

Yes, that’s the one! :smiley:

And you will need to switch it back to AT Command mode if you ever need to use AT commands on that port…

One more question, now i can work with the USB wonderfully, but in the data handler always return TRUE. I dont know exactly how i need to handle this event. And when i try to send something, and exeption appears.