Problems reading uart 2


#1

Hi everybody, we don’t know if anybody have tried to use the UART #2 in wavecom’s q64, anyway, we were wondering if anybody could help us with the second problem we mention in this post:

after reading the ADL User Guide for Open AT® OS v6.30 and some c language books, we figure out that the example in section 3.39.4 of the guide mention before may have a mistake.

Problem #1:
we used to get the following error after we try to build the project in M2M:

request for member ‘write’ in something not a structure or union

We figure out that that error was generated because the example was using a pointer to a structure therefore instead of using uart_if.write( uart_hdl, “Tx Some bytes”, 13 ); it should have been uart_if->write( uart_hdl, “Tx Some bytes”, 13 );

We could see this because uart_if was initialized as:
static psGItfCont_t uart_if;
so if we keep following the pieces of bread, we see that into the header file wm_uart.h it includes wm_device.h which has defined the following structure:

typedef struct
{
//[IMPROV]: what about storing additional Interface attributs …
eChStatus_t ( read ) ( u32 Handle, void pData, u32 amount );
eChStatus_t ( write ) ( u32 Handle, void pData, u32 length );
eChStatus_t ( io_control )( u32 Handle, u32 Cmd, void pParam );
eChStatus_t ( *close ) ( u32 Handle );
} sGItfCont_t, *psGItfCont_t, **ppsGItfCont_t;

as you can see psGItfCont_t anything that is defined as psGItfCont_t will be consider as a pointer to that structure.

Problem #2:
Well, now we can write but we can’t read the UART2, we know we may be making some silly mistake while using the function read but we have spend a long time trying to figure out what the problem could be. We really appreciate if there is anybody who could help us solve this problem, the code we are using is the following (we are just trying to get one byte for now but we can’t get nothing):

#include “adl_global.h”
#include “adl_OpenDevice.h”
#include “wm_uart.h”
#include “q64_init.h”

const u16 wm_apmCustomStackSize=2048*8;

static psGItfCont_t uart_if;
static u32 uart2_hdl;
static u8 rx_buf[ 256 ];

void TtempoHandler(u8 ID, void *Context);
bool InicioHandler(adl_atUnsolicited_t *paras);

void adl_main( adl_InitType_e InitType )
{
q64_Main_Init();
adl_atUnSoSubscribe("+WIND: 7", InicioHandler);
}

bool InicioHandler(adl_atUnsolicited_t *paras)
{
sUartSettings_t settings;
psUartLc_t line_coding;
// Set the line coding parameters
line_coding->valid_fields = UART_LC_ALL;
line_coding->rate = (eUartRate_t)( UART_RATE_USER_DEF | 57600 );
line_coding->stop = UART_STOP_BIT_1;
line_coding->data = UART_DATALENGTH_8;
line_coding->parity = UART_PARITY_NONE;
// UART2 will be opened in NULL MODEM role / with synchronous read/write
settings.identity = “UART2”;
settings.role = UART_ROLE_NM;
settings.capabilities = NULL;
settings.event_handlers = NULL;
settings.interface = &uart_if;
settings.line_coding = line_coding;
uart2_hdl = adl_OpenDevice( DF_UART_CLID, &settings );
if( !uart2_hdl )
{
adl_atSendResponse ( ADL_AT_UNS, “we failed” );
// UART2 opening failed…
return FALSE;
}
// UART2 successfully opened, write some bytes
uart_if->write( uart2_hdl, “Tx Some bytes”, 13 );
adl_tmrSubscribe(TRUE,10,ADL_TMR_TYPE_100MS,TtempoHandler);
return TRUE;
}

void TtempoHandler(u8 ID, void *Context)
{
ascii *text = adl_memGet(100);
uart_if->read( uart2_hdl, rx_buf, 3 );
wm_sprintf(text,"%d\n",rx_buf[1]);
adl_atSendResponse ( ADL_AT_UNS, text);
adl_memRelease(text);
}