Documentation error: UART Direct Access - Async Read Example

There are 2 errors in the above:

  1. IOC_UART_CB does not exist - it should be IOC_UART_EH
  2. uart_if should be uart_if.read - surely?

And what’s with the cb_list[5] - who on earth thought that magic numbers would be a good idea here :question: :open_mouth: :angry: :unamused:

The rxc_handler in the example is also wrong:

The evt_par parameter is a pointer - so the ’’ operator is needed to access the structure members.

Im trying to do the same as you. But when i call the Read function i have an exception.

void on_rxc_handler(u32 user_data,psGData_t evt_par)
{
TRACE((1,"[wav_Serie.c][]:on_rxc_handler"));
//*(u64*)evt_par->buf = 0LL;
(*evt_par).buf = 0LL;
}



void SERIE_Read(void)
{
TRACE((1,"[wav_Serie.c][uart_open]:Inside SERIE_Read"));
sUartEvent_t setting;
u8 *Buffer;
Buffer=adl_memGet(10);

setting.op=G_IOC_OP_SET;
setting.valid_cb=UART_CB_ON_RX_COMPLETE;
setting.user_data=(void*)-1L;
setting.cb_list[5].evt_hdl=(pGEvtNotif_t)on_rxc_handler;
setting.cb_list[5].user_data=(void*)-1L;
if(uart_itf.io_control(handle,IOC_UART_EH,&setting))
	{
	TRACE((1,"an error ocurred"));
	}
else
	TRACE((1,"uart_itf.io_control OKAS!"));

if(CH_STATUS_NORMAL == uart_itf.read( on_rxc_handler, Buffer, 10))
{
TRACE((1,"uart_itf.read OK"));
}



}

Thinking about it, I’m not so sure now - there’s too much casting & dereferencing going on there…

The point here is that examples are supposed to aid understanding - not add confusion!

Such examples are not the place for the authors to show how “clever” they are in writing “tight” source code!
(if you like that kind of thing, go to http://www.ioccc.org/)

The same goes for this kind of nonsense:

if( 0 < (handle = adl_OpenDevice( DF_UART_CLID, &Settings)) )

It’s not helpful, and it’s not necessary.

I think you are getting confused between a handle and a handler

Thanks!, that worked!. But, now im havin an ERROR int this particular part.
I use the same handle that i previously used to open the uart.

if(uart_itf.io_control(handle,IOC_UART_EH,&setting))
	{
	TRACE((1,"an error ocurred"));
	}

I dont know what im doing wrong. And i share all the things you said before, this should be really easy to use, its only a tool to develop things. We should be only worried about the develop itself and not to be guessing what to do.

Since this isn’t really related to the initial subject of this thread - viz, the errors in the example in the ADL User Guide - it might be better to split out to a new thread to examine your specific problem?