Example #1
0
static void
gps_state_init( GpsState*  state )
{
    state->init       = 1;
    state->control[0] = -1;
    state->control[1] = -1;
    state->fd         = -1;

    state->fd = qemud_channel_open(QEMU_CHANNEL_NAME);

    if (state->fd < 0) {
        D("no gps emulation detected");
        return;
    }

    D("gps emulation will read from '%s' qemud channel", QEMU_CHANNEL_NAME );

    if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
        LOGE("could not create thread control socket pair: %s", strerror(errno));
        goto Fail;
    }

    if ( pthread_create( &state->thread, NULL, gps_state_thread, state ) != 0 ) {
        LOGE("could not create gps thread: %s", strerror(errno));
        goto Fail;
    }

    D("gps state initialized");
    return;

Fail:
    gps_state_done( state );
}
Example #2
0
static void
qemu_gps_cleanup(void)
{
    GpsState*  s = _gps_state;

    if (s->init)
        gps_state_done(s);
}
Example #3
0
static void
athr_gps_cleanup(void)
{
    GpsState*  s = _gps_state;

	D("%s: called", __FUNCTION__);

    if (s->init)
        gps_state_done(s);
}
Example #4
0
static void gps_state_init( GpsState*  state, GpsCallbacks* callbacks )
{
    state->init       = 1;
    state->control[0] = -1;
    state->control[1] = -1;
    state->fd         = -1;

    //state->fd = qemud_channel_open(QEMU_CHANNEL_NAME);
	state->fd = open(GPS_Serial_Name, O_RDONLY);
    if (state->fd < 0) {
       D("gps Open SerialPort fail\n");
		state->init = 0;
        return;
    }

// disable echo on serial lines
	if (isatty(state->fd)) {
		struct termios ios;
		tcgetattr(state->fd, &ios);
		ios.c_lflag = 0; /* disable ECHO, ICANON, etc... */
		ios.c_oflag &= (~ONLCR); /* Stop \n -> \r\n translation on output */
		ios.c_iflag &= (~(ICRNL | INLCR)); /* Stop \r -> \n & \n -> \r translation on input */
		ios.c_iflag |= (IGNCR | IXOFF); /* Ignore \r & XON/XOFF on input */
		cfsetispeed(&ios, B9600);
		cfsetospeed(&ios, B9600);
		tcsetattr(state->fd, TCSANOW, &ios);
	}

    //D("gps emulation will read from '%s' qemud channel", GPS_Serial_Name );

    if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
        LOGE("could not create thread control socket pair: %s", strerror(errno));
        goto Fail;
    }

    state->callbacks = *callbacks;
    state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );

    /*if ( !state->thread ) {
        LOGE("could not create gps thread: %s", strerror(errno));
        goto Fail;
    }*/

    D("gps state initialized");
    return;

Fail:
    gps_state_done( state );
}
static void
gps_state_init( GpsState*  state, GpsCallbacks* callbacks )
{
    struct termios tio;
    speed_t speed;
    char device[PATH_MAX], propBuf[PROPERTY_VALUE_MAX];

    state->init       = 1;
    state->control[0] = -1;
    state->control[1] = -1;
    state->fd         = -1;

    property_get("ro.kernel.android.gps", propBuf, "ttyUSB0");
    snprintf(device, sizeof(device), "/dev/%s", propBuf);
    if ((state->fd = open(device, O_RDWR | O_NONBLOCK | O_NOCTTY)) == -1)
        state->fd = open(device, O_RDONLY | O_NONBLOCK | O_NOCTTY);

    if (state->fd < 0) {
        D("no gps detected");
        return;
    }

    if (isatty(state->fd) != 0) {
        if (tcgetattr(state->fd, &tio) == -1) {
            LOGE("tcgetattr: %s", strerror(errno));
            goto Fail;
        }
        tio.c_iflag = tio.c_oflag = tio.c_lflag = 0;
        tio.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD | CRTSCTS);
        tio.c_cflag |= CS8 | CREAD | CLOCAL;
        memset(tio.c_cc, 0, sizeof(tio.c_cc));
        tio.c_cc[VMIN] = 1;

        property_get("gps.serial.speed", propBuf, "4800");
        switch (atoi(propBuf)) {
        case 300:
            speed = B300;
            break;
        case 1200:
            speed = B1200;
            break;
        case 2400:
            speed = B2400;
            break;
        case 4800:
            speed = B4800;
            break;
        case 9600:
            speed = B9600;
            break;
        case 19200:
            speed = B19200;
            break;
        case 38400:
            speed = B38400;
            break;
        case 57600:
            speed = B57600;
            break;
        case 115200:
            speed = B115200;
            break;
        default:
            speed = B0;
            break;
        }

        if (speed != B0) {
            cfsetispeed(&tio, speed);
            cfsetospeed(&tio, speed);
        }

        if (tcsetattr(state->fd, TCSANOW, &tio) == -1) {
            LOGE("tcsetattr: %s", strerror(errno));
            goto Fail;
        }
    }

    D("gps will read from '%s'", device);

    if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
        LOGE("could not create thread control socket pair: %s", strerror(errno));
        goto Fail;
    }

    state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );

    if ( !state->thread ) {
        LOGE("could not create gps thread: %s", strerror(errno));
        goto Fail;
    }

    state->callbacks = callbacks;

    D("gps state initialized");
    return;

Fail:
    gps_state_done( state );
}
Example #6
0
static void
gps_state_init( GpsState*  state )
{
    int    ret;
    int    done = 0;

    struct sigevent tmr_event;

    state->init       = STATE_INIT;
    state->control[0] = -1;
    state->control[1] = -1;
    state->fd         = -1;
    state->fix_freq   = -1;
    state->first_fix  = 0;
	continue_thread = 1;

    if (sem_init(&state->fix_sem, 0, 1) != 0) {
      D("gps semaphore initialization failed! errno = %d", errno);
      return;
    }

    // look for a kernel-provided device name
    if (property_get("athr.gps.mode",prop,"hosted") == 0)
    {
      DFR("Running ATHR GPS driver in hosted mode!");
      if (property_get("athr.gps.node",prop,"") == 0)
      {
        DFR("no user specific gps device name... try default name... ");
        if (property_get("ro.kernel.android.gps",prop,"") == 0)
        {
          DFR("no kernel-provided gps device name (hosted)");
          DFR("please set ro.kernel.android.gps property");
          return;
        }
      }
    }else /* not hosted mode */
    {
      if (property_get("ro.kernel.android.gps",prop,"") == 0)
      {
        DFR("no kernel-provided gps device name (not hosted)");
        DFR("please set ro.kernel.android.gps property");
        return;
      }
    }


    if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
        ALOGE("could not create thread control socket pair: %s", strerror(errno));
        goto Fail;
    }

	state->thread = state->callbacks.create_thread_cb("athr_gps", gps_state_thread, state);
        if (!state->thread)
	{
        ALOGE("could not create gps thread: %s", strerror(errno));
        goto Fail;
    }
        state->callbacks.set_capabilities_cb(GPS_CAPABILITY_SCHEDULING);
	D("gps state initialized");

    return;

Fail:
    gps_state_done( state );
}
Example #7
0
static void
gps_state_init( GpsState*  state )
{
		char   prop[PROPERTY_VALUE_MAX]; 
		char   device[256];
		char 	 buf[10];
    int 	 ret;
		
    state->init       = 0;
    state->control[0] = -1;
    state->control[1] = -1;
    state->fd         = -1;
#if GPS_GPIO_INCLUDE
    state->fdGps      = -1;
#endif

		LOGI("gps_state_init"); 
		
		if (property_get("ro.machine.type",prop,"") == 0) {
        LOGE("no ro.machine.type prop");
    }
    
//    LOGD("ro.machine.type=%s",prop);
    
//     if(memcmp(prop,"yho",3))
//    {
//    	 LOGE("no ro.machine.type is not yho");
//    	 return;
//    }
    
    sprintf(device, "/dev/%s", GPS_CHANNEL_NAME);

	state->fd = open(device, O_RDONLY);
	if(state->fd < 0){
		LOGE("No gps hardware detected (Device %s not found!)", device);
		return;
	}
	{
	    struct termios  ios;
	    tcgetattr( state->fd, &ios );
	    ios.c_lflag = 0;  /* disable ECHO, ICANON, etc... */
	    cfsetospeed(&ios, B9600);
	    cfsetispeed(&ios, B9600);
	    tcsetattr( state->fd, TCSANOW, &ios );
	}
	
#if GPS_GPIO_INCLUDE
    state->fdGps = open(GPS_GPIO_DEV_NAME, O_RDWR);                               // Gps_GPIO
    LOGD("starview : Gps_GPIO Device Open FDescriptor %d",state->fdGps);

    if (state->fdGps < 0) {
        LOGE("starview : Couldn't open gps_gpio");
        close( state->fd ); 
        state->fd = -1;  
        return;
    }
    ret = sprintf(buf,"%d\n",1);
    ret = write(state->fdGps, buf, ret);
#endif

    if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
        LOGE("could not create thread control socket pair: %s", strerror(errno));
        goto Fail;
    }
#if 0
    if ( pthread_create( &state->thread, NULL, gps_state_thread, state ) != 0 ) {
        LOGE("could not create gps thread: %s", strerror(errno));
        goto Fail;
    }
#else
		state->callbacks.create_thread_cb("qemu_gps",  gps_state_thread, state);
#endif
		state->init = 1;
    D("gps state initialized");
    return;

Fail:
    gps_state_done( state );
}
Example #8
0
static void
gps_state_init( GpsState*  state, GpsCallbacks* callbacks )
{
	struct termios termios;

    state->init       = 1;
    state->control[0] = -1;
    state->control[1] = -1;
    state->fd         = -1;

    if( s3c_channel_open_tty(state) < 0 ) {
        D("s3c :fail! set s3c_channel_open_tty()");
        return;
    }

    state->fd = open(state->device, O_RDWR | O_NONBLOCK | O_NOCTTY);

    if (state->fd < 0) {
        D("no gps detected");
        return;
    }

	D("gps uart open %s success!", state->device);

/*
	tcflush(state->fd, TCIOFLUSH);
	tcgetattr(state->fd, &termios);

	termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
                | INLCR | IGNCR | ICRNL | IXON);
	termios.c_oflag &= ~OPOST;
	termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
	termios.c_cflag &= ~(CSIZE | PARENB);
	termios.c_cflag |= CS8;
	termios.c_cflag &= ~CRTSCTS;
	
	tcsetattr(state->fd, TCSANOW, &termios);
	tcflush(state->fd, TCIOFLUSH);
	tcsetattr(state->fd, TCSANOW, &termios);
	tcflush(state->fd, TCIOFLUSH);
	tcflush(state->fd, TCIOFLUSH);

	cfsetospeed(&termios, B115200);
	cfsetispeed(&termios, B115200);
	tcsetattr(state->fd, TCSANOW, &termios);
*/

    D("gps will read from %s", state->device);

    if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, state->control ) < 0 ) {
        LOGE("could not create thread control socket pair: %s", strerror(errno));
        goto Fail;
    }

    state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );

    if ( !state->thread ) {
        LOGE("could not create gps thread: %s", strerror(errno));
        goto Fail;
    }

    state->callbacks = *callbacks;

    D("gps state initialized");
    return;

Fail:
    gps_state_done( state );
}
void serial_gps_cleanup(void) {
    GpsState*  s = _gps_state;

    if (s->init)
        gps_state_done(s);
}