# mangOH green: golang and positioning

**URL:** https://mangoh.discourse.group/t/mangoh-green-golang-and-positioning/1533
**Category:** mangOH Green
**Created:** [June 9, 2018, 10:39pm UTC](https://mangoh.discourse.group/t/mangoh-green-golang-and-positioning/1533 "2018-06-09T22:39:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![magiconair](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/magiconair/32/490_2.png) [@magiconair](https://mangoh.discourse.group/u/magiconair)
#### Post date: [June 9, 2018, 10:39pm UTC](https://mangoh.discourse.group/t/mangoh-green-golang-and-positioning/1533/1 "2018-06-09T22:39:18Z")

</div>

Hi,

I am trying to access the positioning service from a Go app and I’m stuck on starting the positioning service. Generally, how do you use Legato services from 3rd party apps (in my case a Go app)?

I am using `bundles` to package the app or just copy the binary to the mangOH green to see whether it works at all.

When I run the app I get `le_posCtrl_ConnectService() not called for current thread`. I’m assuming that I need to start the positioning service somehow and that this is achieved through the `bindings` section in the `.adef` file.

```auto
$ cat Makefile
CC=/opt/swi/y17-ext/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.9.1/gcc
build: clean
	CC=$(CC) GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 go build

scp: build
	scp gps root@192.168.2.2:

instapp: build
	mkapp -v -t wp750x gps.adef
	instapp gps.wp750x.update 192.168.2.2

ifgen:
	ifgen --gen-interface --gen-client --gen-local $(LEGATO_ROOT)/interfaces/positioning/le_pos.api
	ifgen --gen-interface --gen-client --gen-local $(LEGATO_ROOT)/interfaces/positioning/le_posCtrl.api

clean:
	rm -f *.o
	rm -f gps

```

```auto
$ cat gps.adef
sandboxed: false

version: 1.0.0

bundles:
{
	file:
	{
		[x] gps /bin/gps
	}
}

processes:
{
    run:
    {
        ( gps )
    }
}

```

```auto
$ cat /go/src/gps/main.go

package main

/*
#cgo CFLAGS: -I/legato/framework/c/inc
#cgo LDFLAGS: -L/legato/build/wp750x/framework/lib -llegato

#include <stdio.h>
#include "legato.h"
#include "le_pos_interface.h"
#include "le_posCtrl_interface.h"
*/
import "C"

import "log"
import "time"

func main() {
	log.Print("Starting gps")

	// this never returns
	// log.Print("Calling le_posCtrl_ConnectService()")
	// C.le_posCtrl_ConnectService()

	log.Print("Calling le_posCtrl_Requst()")
	ref := C.le_posCtrl_Request()
	if ref == nil {
		log.Fatal("Cannot activate positioning service")
	}
	defer C.le_posCtrl_Release(ref)

	var lat, lon, acc C.int
	for {
		log.Println("Calling le_pos_Get2DLocation")
		res2 := C.le_pos_Get2DLocation(&lat, &lon, &acc)
		log.Printf("le_pos_Get2DLocation: res: %d lat: %d lon: %d acc: %d\n", res2, lat, lon, acc)
		time.Sleep(500*time.Millisecond)
	}
}

```

Running `make` and copying the file to 192.168.2.2 and running it returns

```auto
Jun 9 22:30:00 swi-mdm9x15 user.emerg Legato: *EMR* | _UNKNOWN_[8337]/framework T=main | LE_FILENAME GetCurrentSessionRef() 320 | le_posCtrl_ConnectService() not called for current thread

```

Adding a call to `le_posCtrl_ConnectService()` at the start never returns.

I’ve then tried adding generic bindings to the `gps.adef` file but with no success.

```auto
...
bindings:
{
    *.le_posCtrl -> positioningService.le_posCtrl
    *.le_pos -> positioningService.le_pos
}

```

`mkapp -v -t wp750x gps.adef` returns

```auto
/go/src/gps/gps.adef:27:6: error: No such client-side pre-built interface 'le_posCtrl'.

```

I’m probably missing something obvious or this isn’t possible. Any help is greatly appreciated.

Update 1: I am using Legato 16.10.3 on a mangOH green with a WP750x

---

<div class="post-metadata">

### Author: ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)
#### Post date: [June 11, 2018, 5:02pm UTC](https://mangoh.discourse.group/t/mangoh-green-golang-and-positioning/1533/2 "2018-06-11T17:02:14Z")

</div>

Have you tried asking on the [Legato forum](https://forum.legato.io)?

---

<div class="post-metadata">

### Author: ![magiconair](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/magiconair/32/490_2.png) [@magiconair](https://mangoh.discourse.group/u/magiconair)
#### Post date: [June 11, 2018, 5:03pm UTC](https://mangoh.discourse.group/t/mangoh-green-golang-and-positioning/1533/3 "2018-06-11T17:03:02Z")

</div>

Actually - no 🙂 I’m somewhat new to this environment. I’ll try thx.
