Hi,

Glad that power safe mode will be implemented into ogpsd.
Although serial port is enough, it's really good if somebody can point out
how to wakeup through EXTINT0.
I've seen UBX binary codes in ogpsd, so the basic implementation is simple.
My codes are written in C instead of Python, so I post pseudo codes here:

enum
{
        FIXNOW_DISABLED,
        FIXNOW_ENABLED,
};
static int fxn_mode = FIXNOW_DISABLED;

/* set CFG-RXM */
unsigned char packet[] = {
        0xB5, 0x62, /* header */
        0x06, 0x11, /* message type: CFG-RXM */
        0x02, 0x00, /* length */
        0x03, /* GPS sensitivity mode: auto */
        0x01, /* low power mode: FixNow */
        0x00, 0x00 /* check sum: to be set */
};

unsigned char wakeup[] = {      0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
                0xB5, 0x62, 0x02, 0x40, 0x00, 0x00, 0x42,0xC8 };

int write_ubx_packet (unsigned char *buf, int size)
{
        if (fxn_mode = FIXNOW_ENABLED) {
                // TBD: write wakeup[];
                sleep(1); /* suitable? */
        }
        int success = 0;
        // TBD: write buf and set success;
        return success;
}

/* see U-BLOX document for more details */
int configure_fxn(unsigned char t_off_minutes)
{
        /* suitable? */
        unsigned char acq_minutes = 3;
        unsigned char acq_off_minutes = 3;

        unsigned char ms_acq = acq_minutes * 60 * 1000;
        unsigned char ms_acq_off = acq_off_minutes * 60 * 1000;
        unsigned char ms_t_on = 15 * 1000; /* 15 seconds, note: suitable? */
        unsigned char ms_t_off = t_off_minutes * 60 * 1000;

        unsigned char req[4], req_off[4], on[4], off[4];

        int i, j;
        for (i=0; i<4; i++) {
                j = i << 3;
                req[i] = (ms_acq >> j) & 0xFF;
                req_off[i] = (ms_acq_off >> j) & 0xFF;
                on[i] = (ms_t_on >> j) & 0xFF;
                off[i] = (ms_t_off >> j) & 0xFF;
        }

        unsigned char packet[] = {
                0xB5, 0x62,
                0x06, 0x0E, /* CFG-FXN */
                36, 0x00, /* length */
                0x02 | 0x10, 0x00, 0x00, 0x00, /* flags */
                req[0], req[1], req[2], req[3], /* t_reacq: default 20 minutes 
*/
                req[0], req[1], req[2], req[3], /* t_acq: default 20 minutes */
                req_off[0], req_off[1], req_off[2], req_off[3], /* t_reacq_off: 
default
100 minutes */
                req_off[0], req_off[1], req_off[2], req_off[3], /* t_acq_off: 
default 100
minutes*/
                on[0], on[1], on[2], on[3], /* t_on */
                off[0], off[1], off[2], off[3], /* t_off */
                0x00, 0x00, 0x00, 0x00, /* res */
                0x00, 0x00, 0x00, 0x00, /* base_tow */
                0x00, 0x00                              /* checksum */
        };
        int success = 0;
        // TBD: checksum the packet and write to serial port, optionally read 
ACK
        return success;
}

#1 enable FXN mode (before suspend?)

        if (! configure_fxn(30)) { /* offtime: suitable? */
                // ignore
        }
        if (fxn_mode == FIXNOW_DISABLED) {
                // 1. checksum packet[]
                // 2. write this packet to serial port, and optionally read ACK 
to check
success or not
                if (success) {
                        fxn_mode == FIXNOW_DISABLED;
                } else {
                        // ignore
                }
        }

#2 disable FXN mode (after resume?)

        if (fxn_mode == FIXNOW_ENABLED) {
                packet[7] = 0x00; /* continuous tracking mode */
                // TBD: checksum packet[]
                int success = 0;
                int fail_counter = 0;
                int max_fails = 5;
                while (! success) {
                        // TBD: write this packet to serial port, and 
optionally read ACK to
check success or not
                        success = ...;
                        if (! success) sleep (1);
                        if (++fail_counter == max_fails) {
                                // TBD: power off then power on
                                break;
                        }
                }
                fxn_mode == FIXNOW_DISABLED;
        }

#3 poll navigation data (no matter in FixNow mode or not)

        // TBD: prepare request packet
        // TBD: call write_ubx_packet()

Regards, 
mqy

In FixNow mode, NOTE: 
1. to save power, the poll interval should not be small enough (e.g, less
than 15 seconds?)
2. occasionally, no fix available
3. my test result shows no NMEA output even the GPS chip is waken up. Need
verify.


Daniel Willmann wrote:
> 
> 
> This sounds quite promising. How was FixNow configured in that case?
> 
> I think you misunderstood that post. In there Andy says that the GPS
> will have no way to wake us up if it has a fix. What is possible is to
> put the GPS into FixNow mode and wake it up either by sending some
> serial data or by toggling the EXTINT0 pin that is routed to our SoC.
> 
> Yeah, page 26f. also states that the receiver can be woken up via
> EXTINT0 and it will compute and send a position in response.
> 
> Would you mind publishing your code? I'm interested in integrating this
> in ogpsd as well. 
> 
> Regards,
> Daniel Willmann 
> _______________________________________________
> Openmoko community mailing list
> community@lists.openmoko.org
> http://lists.openmoko.org/mailman/listinfo/community
> 

-- 
View this message in context: 
http://n2.nabble.com/Good-news%3A-FixNow-mode-can-be-wakenup-through-serial-port-tp2476690p2484337.html
Sent from the Openmoko Community mailing list archive at Nabble.com.


_______________________________________________
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community

Reply via email to