Giter Club home page Giter Club logo

inkview's Introduction

Go SDK for Pocketbook

Unofficial Go SDK for Pocketbook based on libinkview.

Supports graphical user interfaces and CLI apps.

Build a CLI app

Standard Go compiler should be able to cross-compile the binary for the device (no need for SDK):

GOOS=linux GOARCH=arm GOARM=5 go build main.go

Note that some additional workarounds are necessary if you want to access a network from your app. In this case you may still need SDK.

Although this binary will run on the device, you will need a third-party application to actually see an output of you program (like pbterm).

The second option is to wrap the program into RunCLI - it will emulate terminal output and write it to device display.

Preparation - Build or pull the Docker Image

You can pull a docker images from dockerhub:

docker pull 5keeve/pocketbook-go-sdk:6.3.0-b288-v1

To build this image on your own, feel free to use docker-compose.yaml.

docker-compose build

This will create a pb-go service which can be used to compile a go program.

Adjust the source path in docker-compose.yaml to your needs.

With the current settings you can compile the test programs.

E.g.:

docker-compose run --rm pb-go build ./sqlitetst.dir/sqlitetst.go

Note In order to see some output for this, you need to run in using something like pbterm. If you just start it without pbterm you can verify successful execution by attaching your device to your computer and check for the presence of the file sqlite-database.db.

docker-compose run --rm pb-go build ./devinfo/main.go

Alternatively, after building the image, docker can be used to compile without adjusting the file.

Build an app with UI

To build your app or any example, run (requires Docker):

cd ./examples/sqlitetst.dir/
docker run --rm -v $PWD:/app dennwc/pocketbook-go-sdk build -o sqlitetst.app
cd ./examples/devinfo/
docker run --rm -v $PWD:/app dennwc/pocketbook-go-sdk
mv app devinfo.app

You may also need to mount GOPATH to container to build your app:

docker run --rm -v $PWD:/app -v $GOPATH:/gopath dennwc/pocketbook-go-sdk

To run an binary, copy it into applications/app-name.app folder on the device and it should appear in the applications list.

Notes on networking

By default, device will try to shutdown network interface to save battery, thus you will need to call SDK functions to keep device online (see KeepNetwork).

Also note that establishing TLS will require Go to read system certificate pool that might take up to 30 sec on some devices and will lead to TLS handshake timeouts. You will need to call InitCerts first to fix the problem.

IPv6 is not enabled on some devices, thus a patch to Go DNS lib is required to skip lookup on IPv6 address (SDK already includes the patch). Similar problems may arise when trying to dial IPv6 directly.

Notes on workdir

Application will have a working directory set to FS root, and not to a parent directory. To use relative paths properly change local dir to a binary's parent directory: os.Chdir(filepath.Dir(os.Args[0])).

inkview's People

Contributors

dennwc avatar skeeve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

inkview's Issues

Another Question: How to add other go modules?

I'm trying to build an app using github.com/mattn/go-sqlite3 but run into all sorts of weird issues.

Maybe mostly due to the fact that I still do not fully understand go…

I understood that I need to install git into the dockerimage, but when I try to get github.com/mattn/go-sqlite3 the error is

go/bin/go get github.com/mattn/go-sqlite3
package context: unrecognized import path "context" (import path does not begin with hostname)
package crypto/sha1: unrecognized import path "crypto/sha1" (import path does not begin with hostname)
package crypto/sha256: unrecognized import path "crypto/sha256" (import path does not begin with hostname)
package crypto/sha512: unrecognized import path "crypto/sha512" (import path does not begin with hostname)
package database/sql: unrecognized import path "database/sql" (import path does not begin with hostname)
package database/sql/driver: unrecognized import path "database/sql/driver" (import path does not begin with hostname)
package errors: unrecognized import path "errors" (import path does not begin with hostname)
package fmt: unrecognized import path "fmt" (import path does not begin with hostname)
package io: unrecognized import path "io" (import path does not begin with hostname)
package math: unrecognized import path "math" (import path does not begin with hostname)
package net/url: unrecognized import path "net/url" (import path does not begin with hostname)
package reflect: unrecognized import path "reflect" (import path does not begin with hostname)
package runtime: unrecognized import path "runtime" (import path does not begin with hostname)
package strconv: unrecognized import path "strconv" (import path does not begin with hostname)
package strings: unrecognized import path "strings" (import path does not begin with hostname)
package sync: unrecognized import path "sync" (import path does not begin with hostname)
package syscall: unrecognized import path "syscall" (import path does not begin with hostname)
package time: unrecognized import path "time" (import path does not begin with hostname)
package unsafe: unrecognized import path "unsafe" (import path does not begin with hostname)

Can not find libraries

Trying to build example after docker-compose build with docker run --rm -v $PWD:/app -v $GOPATH:/gopath dennwc/pocketbook-go-sdk:latest.
Getting

# github.com/dennwc/inkview
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: skipping incompatible /usr/lib/../lib/libinkview.so when searching for -linkview
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: skipping incompatible //usr/lib/libinkview.so when searching for -linkview
/usr/lib/gcc-cross/arm-linux-gnueabi/5/../../../../arm-linux-gnueabi/bin/ld: cannot find -linkview
collect2: error: ld returned 1 exit status

Though it works fine with the pulled from docker hub image v0.2.

What's required to write a GUI App?

Hi.
I do not understand how to write a GUI app for Pocketbook. Did you already do it? Do you have an example?

I think I need to include some GUI library (which one) to be able to paint windows and buttons and to react to button presses.

But as I never ever did that in any language (besides Javascript in a browser), I'm clueless here.

Do you have some guidance, please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.