Help with gps

but it still doesn’t work
This is very anoying! Could some one please help me out with this

What do you mean, “doesn’t work” ? :unamused:

What traces do you see?

Note that Event handlers only ever receive a single Event - so a switch would be more appropriate than ifs…

TRACE (( 1, "fcm data %d",*Data));

What result do you see from this?

You might find the DUMP macro more appropriate here…

fcmHandle=adl_fcmSubscribe( ADL_FCM_FLOW_V24_UART1, (adl_fcmCtrlHdlr_f)fcmControlHandler, (adl_fcmDataHdlr_f)fcmDataHandler );

You haven’t checked the return result here - maybe it gives an error…?

when i say that is doesn’t work i mean everything is ok i switch to data mode ok but after that nothing happens. I get the traces:
Trace CUS4 1 fcm control handler event 0
Trace CUS4 1 switching do data state
Trace CUS4 1 fcm control handler event 2
Trace CUS4 1 Now in data mode

after this at some point i would aspect to datahandler to be called and
TRACE (( 1, “fcm data %d”,*Data));
doesn’t diplay anything
DUMP macro sorry i am not familiar with this (like i said i stared working with open at only a few days ago)

  1. Have you configured the UART (prior to opening flows) to the same speed as the GPS sends its NMEA data in? 4800,8n1 is the common setting for that, but it varies between providers.
  2. Do you receive NMEA data if you connect the GPS to a PC via serial cable?

The DUMP macro is documented in exactly the same place as the TRACE macro; viz in the ADL User Guide for Open-AT
Look in the section titled, “Debug traces”

All the more important to start with the basics - like a review of the supplied documentation.

Have you worked through the example projects - there’s a “Hello, world” example that illustrates the use of UART1 and FCM…

This is very important!

Remember: as far as the FCM is concerened, it deals only with serial data - it neither knows nor cares whether that serial data comes from a PC, a GPS unit, a terminal, a vending machine, or anything else!

Therefore, you should start by verifying that that you can send serial data to a PC, and receive from a PC - using hypoterminal, or whatever.
Once you know that the basic serial IO works, then you can try it with the GPS unit…

the hello world applicaiton is subscribes to a timer and prints out some text and that’s it
And the other examples don’t use gps

i connect the gps module to the modem by a SMA male connector not by a serial cable
on the modem there is a basic application that has an at command that shows the current gps position so the gps works and can communicate with the modem i just can’t write some code that does the same thing
i tried to set the baud rate
with ipr but still after a succesfull change to data mode the data handler function is not called
[/quote]

Are you sure that’s the actual GPS module you’re connecting?

Are you sure that it’s not just the GPS antenna…?!

It would be rather unusual :exclamation: to use an SMA connector for serial data! :open_mouth:

Then again, if this GPS module does not provide serial data, then you obviously won’t be able to talk to it over a UART!

It has already been noted that this is a Wavecom-specific forum; as you’re using a non-Wavecom product, I think you need to check with the manufacturer to determine exactly how the GPS data reaches the Wismo module within their product.

Or perhaps you could post a link to the technical specs for this unit?

I think you need to look here:

gener.fr/UK/genloc31e.php

In particular, see section 11 in the User Guide - “Client Support” - there is mention of Application Notes…

Looking at the User Guide and the pictures, I’d be pretty sure that you are just talking about the GPS antenna :exclamation:

It also looks extremely likely that UART1 is going to be connected to the external RS232 connector - just as in a Fastrack - so the GPS most probably must be connected to something else!
You need to contact Erco & Gener for the details of this - it might not even use a UART at all!

ok guys thank you all for your help i figured it out
the problem was that the gps was held in reset so all i needed to do is to not hold it in reset and indeed that data started arriving in my datahandler :smiley:
Here is the code maybe somebody will have the same problem
/**************************************************************************/
/
Local variables /
/
**************************************************************************/
//u8 fcmHandle;
#define UART2_CLOSED 0
#define UART2_GETTING_STATUS 1
#define UART2_CLOSED_WAITING_OK 2
#define UART2_OPENING_WAITING_OK 3
#define UART2_OPEN_WAITING_OK 4
#define UART2_OPEN 5
#define UART2_CHANGING_SPEED 6
#define UART2_OPENING_FCM 7
#define UART2_READY 8
typedef enum
{
UART_MODE_AT,
UART_MODE_DATA
} uartModeType_e;
bool b_canSendDataToUart2 = TRUE;
u8 uart2Mode = UART_MODE_AT;
bool gps_resetMode = 0;
s8 GPIO1_Handle;
s8 FCM_UART2_handle;
u8 uart2Status = UART2_CLOSED; // to manage to the starting of UART2
/**************************************************************************/
/
Local functions /
/
**************************************************************************/
void startGpsBlock(void)
{
TRACE (( 1, “startGpsBlock” ));

// select mode 1. ADC_C corresponds to the Antenna voltage
adl_atCmdCreate( "AT+ADC=1", FALSE, ( adl_atRspHandler_t ) NULL, NULL);

// Release the reset of the GPS block now that the UART2 is open and its FCM is in DATA mode
gps_resetMode = 1;
adl_ioWrite(GPIO1_Handle, ADL_IO_Q24X6_GPO_1, ADL_IO_Q24X6_GPO_1); // reset set high

//subscribeToCmdsUbx(); // send UBX config frames after UART2 and Reset are valid

//getAdcVoltages();     // get startup voltage of unpowered GPS antenna

#ifdef DELAYED_ANALYSE_RX_FRAMES
// start the cyclic timer to analyse received frames
//TIMER_CHECKBUFFER_handle = adl_tmrSubscribe ( TRUE, 1, ADL_TMR_TYPE_100MS, tmrHandler_checkRxBuffer );
#endif

// start antenna monitoring timer
//TIMER_ANTENNA_MONITOR_handle = adl_tmrSubscribe ( TRUE, 10, ADL_TMR_TYPE_100MS, tmrHandler_antenna_monitor );

}
// Control handler for UART 2
bool FCM_UART2_CtrlHandler(adl_fcmEvent_e Event)
{
s8 resultat;
TRACE (( 1, “FCM_UART2_CtrlHandler” ));

switch(Event)
{
case ADL_FCM_EVENT_FLOW_OPENNED:
    TRACE (( 1, "ADL_FCM_EVENT_FLOW_OPENNED" ));
    resultat = adl_fcmSwitchV24State(FCM_UART2_handle, ADL_FCM_V24_STATE_DATA);
    break;

case ADL_FCM_EVENT_FLOW_CLOSED:
    TRACE (( 1, "ADL_FCM_EVENT_FLOW_CLOSED" ));
    break;

case ADL_FCM_EVENT_V24_DATA_MODE:
    TRACE (( 1, "ADL_FCM_EVENT_V24_DATA_MODE" ));
    uart2Mode = UART_MODE_DATA;
    uart2Status = UART2_READY;  // UART2 is now completely initialised
    startGpsBlock();            // can now start GPS block
adl_ioWrite(GPIO1_Handle, ADL_IO_Q24X6_GPO_1, ADL_IO_Q24X6_GPO_1); // reset set high
    break;

case ADL_FCM_EVENT_V24_DATA_MODE_EXT:
    TRACE (( 1, "ADL_FCM_EVENT_V24_DATA_MODE_EXT" ));
    break;

case ADL_FCM_EVENT_V24_AT_MODE:
    TRACE (( 1, "ADL_FCM_EVENT_V24_AT_MODE" ));
    uart2Mode = UART_MODE_AT;
    break;

case ADL_FCM_EVENT_V24_AT_MODE_EXT:
    TRACE (( 1, "ADL_FCM_EVENT_V24_AT_MODE_EXT" ));
    break;

case ADL_FCM_EVENT_RESUME:
    TRACE (( 1, "ADL_FCM_EVENT_RESUME" ));
    b_canSendDataToUart2 = TRUE;
 //   sendBufToUart2();
    break;

case ADL_FCM_EVENT_MEM_RELEASE:
    TRACE (( 1, "ADL_FCM_EVENT_MEM_RELEASE" ));
    break;

case ADL_FCM_EVENT_V24_DATA_MODE_FROM_CALL:
    TRACE (( 1, "ADL_FCM_EVENT_V24_DATA_MODE_FROM_CALL" ));
    break;

case ADL_FCM_EVENT_V24_AT_MODE_FROM_CALL:
    TRACE (( 1, "ADL_FCM_EVENT_V24_AT_MODE_FROM_CALL" ));
    break;

default:
    TRACE (( 1, "DEFAULT" ));
    break;
}

return(FALSE);

}

/***************************************************************************/
// Data handler for UART 2
bool FCM_UART2_DataHandler(u16 DataSize, u8 * Data)
{
u16 i;
u8 * pData = Data;

// TRACE (( TRACE_LEVEL_FCT, "FCM_UART2_DataHandler" ));
 TRACE (( 1, "Datasize: %d", DataSize));

 
return(TRUE);

}

//**************************************************************************
// Subscribe to the UART2 FCM after a short delay
void tmrHandler_startFcmUart2( u8 ID )
{
// Subscribe to the FCM for UART2
FCM_UART2_handle = adl_fcmSubscribe ( ADL_FCM_FLOW_V24_UART2, FCM_UART2_CtrlHandler, FCM_UART2_DataHandler );

TRACE (( 1, "adl_fcmSubscribe UART2 return value: %d", FCM_UART2_handle ));

if(FCM_UART2_handle < 0)
    TRACE (( 1, "adl_fcmSubscribe UART2 failed" ));

}

//----------------------------------------------------------------------------------------
// Check that OK is received after setting UART2 default speed
// If OK, wait, then subscribe to the FCM for UART2
//----------------------------------------------------------------------------------------
bool cmd_RspHandler_IPR(adl_atResponse_t * params)
{
ascii buf[30];

TRACE (( 1, "cmd_RspHandler_IPR" ));

wm_strRemoveCRLF(buf, params->StrData, params->StrLength);

if ((!wm_strcmp(buf, "OK")) && (uart2Status == UART2_CHANGING_SPEED))
{
    uart2Status = UART2_OPENING_FCM;
    // Must wait before subscribing to the FCM for UART 2,
    // otherwise the UART2 parameters are not set correctly
    // and the UART2 is not synchronised to the incomming data.
    adl_tmrSubscribe ( FALSE, 1, ADL_TMR_TYPE_100MS, tmrHandler_startFcmUart2 );
}

return FALSE;

}

//----------------------------------------------------------------------------------------
// Response handler after requesting/modifying UART2 status.
// If UART2 is closed then open it. Once open, then change speed.
// If it is already open, then leave it open and change speed.
//----------------------------------------------------------------------------------------
bool cmd_RspHandler_WMFM(adl_atResponse_t * params)
{
ascii buf[30];

wm_strRemoveCRLF(buf, params->StrData, params->StrLength);

switch(uart2Status)
{
case UART2_GETTING_STATUS:
    if(buf[13] == '0')      // "+WMFM: 0,2,x,0" ==> Closed
    {
        uart2Status = UART2_CLOSED_WAITING_OK;
    }
    else if(buf[13] == '1') // "+WMFM: 0,2,x,1" ==> Open
    {
        uart2Status = UART2_OPEN_WAITING_OK;
    }
    break;

case UART2_CLOSED_WAITING_OK:
    if(!wm_strcmp(buf, "OK"))
    {
        uart2Status = UART2_OPENING_WAITING_OK;
        // By default, only UART 1 is open. UART 2 must be explicitly opened
        adl_atCmdCreate( "AT+WMFM=0,1,2", FALSE, ( adl_atRspHandler_t ) cmd_RspHandler_WMFM, "*", NULL );
    }
    break;

case UART2_OPEN_WAITING_OK:
    if(!wm_strcmp(buf, "OK"))
    {
        uart2Status = UART2_CHANGING_SPEED;
        // Set default speed for UART 2
        adl_atCmdCreate("AT+IPR=9600", ADL_AT_PORT_TYPE( ADL_AT_UART2, FALSE ), (adl_atRspHandler_t) cmd_RspHandler_IPR, "*", NULL);
    }
    break;

case UART2_OPENING_WAITING_OK:
    if(!wm_strcmp(buf, "OK"))
    {
        uart2Status = UART2_GETTING_STATUS;
      //  startUart2();   // get status of UART2 again. Should be open now
    }
    break;

}

return FALSE;

}
void startGpio1(void)
{
// subscribe to GPIO1
GPIO1_Handle = adl_ioSubscribe ( ADL_IO_Q24X6_GPO_1, // GpioMask
~ADL_IO_Q24X6_GPO_1, // GpioDir en sortie = 0
~ADL_IO_Q24X6_GPO_1, // GpioDefValues = 0
0, // PollingTime
0 ); // GpioHandler

if ( GPIO1_Handle >=0 )
{
    gps_resetMode = 0;
    adl_ioWrite(GPIO1_Handle, ADL_IO_Q24X6_GPO_1, ~ADL_IO_Q24X6_GPO_1); // reset set low
    TRACE (( 1, "ADL_IO_Q24X6_GPO_1, handle: %d", GPIO1_Handle ));
    TRACE (( 1, "(adl_main)ADL_IO_Q24X6_GPO_1 = 0"));
}

}
// Start by getting status of UART2
void startUart2(void)
{
// Get UART2 status first.
// If we try to open it when all ready open, then an error is returned.
// Similarly, if we try to close it when all ready closed, then an error is returned.
// So check status first and then act accordingly.
TRACE (( 1, “startUart2: get status UART2” ));
uart2Status = UART2_GETTING_STATUS;
adl_atCmdCreate( “AT+WMFM=0,2,2”, FALSE, ( adl_atRspHandler_t ) cmd_RspHandler_WMFM, “*”, NULL );
}

/*******************************************************************/
/
Function : adl_main /
/
-------------------------------------------------------------------------
/
/
Object : Customer application initialisation /
/
/
/
-------------------------------------------------------------------------
/
/
Variable Name |IN |OUT|GLB| Utilisation /
/
--------------------±–±--±–±---------------------------------------
/
/
InitType | | | | Application start mode reason /
/
--------------------±–±--±–±---------------------------------------
/
/***************************************************************************/

void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, “Embedded Application : Main” ));

//adl_atCmdCreate(“AT+IPR=9600”, ADL_AT_PORT_TYPE( ADL_AT_UART2, FALSE ),(adl_atRspHandler_t) Res_IPR_Handler,"*", NULL);
startGpio1();
startUart2();
}

But I think that the voltage given by the UART should be at the same TTL level with the voltage given by the GPS in the serial connection. For example, UART2 gives 1.8 V, but the GPS I want to use gives minimum 2 V. So I suppose (I haven’t tried it yet because I want to be absolutely sure about it before burning something!!) that if I connect the RX2->TXgps and TX2->RXgps, then the UART won’t “feel” anything! Am I right? Please somebody can answer this?

Furthermore, in Wavecom’s datasheet it says that if somebody wants to use only the 2 wires from UART2, it is forbidden to use AT commands. My GPS gives only a RX and TX, nothing about RTS, CTS, so I was wondering whether it would be possible to connect and work properly with this serial connection in this way!

Thanks in advance!

Yes, of course the physical interface has to be correctly designed!

So, obviously, you need some kind of voltage translation device between them!

Be sure to check that you connect the output from the GPS to the input of the Wavecom module.

Because the Wavecom module is a DCE (ie, a modem) its “Tx” pin is an input - it is the data to be transmitted over the comms link

Thanks a lot awneil! Are you sure about this? It seems such a strange setting!!!

Don’t take my word for it - confirm it for yourself in the Datasheet!

Confirmed in the Q2686 pts sheet… Thanks for pointing that one out :slight_smile: this just saved me a whole load of future trouble.

Hi guys!

I would like some help with my gps connection.I have connected via UART2 my gps with my wavecom’s q2686 module but my problem is my following:

In fcm_data_handler function I have the following code:

bool FCM_UART2_DataHandler(u16 DataSize, u8 * Data)
{
u16 i;
pData = Data;

TRACE (( TraceLevel, "DataHandler" ));
TRACE (( TraceLevel, "Datasize: %d", DataSize));
MessageBox(NULL,pData,"GPS DATA",0);
//TRACE (( TraceLevel, "DATA:" pData));

return(TRUE);
}

And in Target monitoring tool I get the following traces:

Trace IP 1 DataHandler
Trace IP 1 Datasize: 2
Trace IP 1
Trace IP 1 DataHandler
Trace IP 1 Datasize: 1
Trace IP 1
Trace IP 1 DataHandler
Trace IP 1 Datasize: 1
Trace IP 1
Trace IP 1 DataHandler
Trace IP 1 Datasize: 1
Trace IP 1
Trace IP 1 DataHandler
Trace IP 1 Datasize: 1
Trace IP 1
Trace IP 1 DataHandler
Trace IP 1 Datasize: 1
Trace IP 1
Trace IP 1 DataHandler
Trace IP 1 Datasize: 110
Trace IP 1

Which means that my module gets the gps blocks but there are empty or somehting… What is wrong with that? Please somebody help me!

Thanks in advance!

No they aren’t - it’s telling you that they have sizes of 2, 1, 1, … 110

What does your “MessageBox” function do?

Have you tried just using DUMP to see the raw bytes?

MessageBox does the same as TRACE but it pumps a Windows box with the data. I used this in case the TRACE didn’t show correctly the data received…but with the same result!

What is DUMP? I didn’t know anything about it!
Do you mean (by saying raw bytes) that I can be able to see each bit or maybe byte voltage level?

How does it do that?! :confused: :open_mouth: :question:

RTFM: It is documented in the ADL Manual - in the same place as TRACE!

I mean you can see the Hex value of each byte - in case non-ASCII values are getting misinterpreted…