GithubHelp home page GithubHelp logo

device-gpio's Introduction

GPIO Device Service

Build Status Go Report Card GitHub Latest Dev Tag) GitHub Latest Stable Tag) GitHub License GitHub go.mod Go version GitHub Pull Requests GitHub Contributors GitHub Committers GitHub Commit Activity

Warning
The main branch of this repository contains work-in-progress development code for the upcoming release, and is not guaranteed to be stable or working. It is only compatible with the main branch of edgex-compose which uses the Docker images built from the main branch of this repo and other repos.

The source for the latest release can be found at Releases.

Documentation

This device service is contributed by Jiangxing Intelligence

For latest documentation please visit https://docs.edgexfoundry.org/latest/microservices/device/services/device-gpio/Purpose

Build Instructions

  1. Clone the device-gpio repo with the following command:

     git clone https://github.com/edgexfoundry/device-gpio.git
    
  2. Build a docker image by using the following command:

     make docker
    
  3. Alternatively the device service can be built natively:

     make build
    

Build with NATS Messaging

Currently, the NATS Messaging capability (NATS MessageBus) is opt-in at build time. This means that the published Docker images do not include the NATS messaging capability.

The following make commands will build the local binary or local Docker image with NATS messaging capability included.

make build-nats
make docker-nats

The locally built Docker image can then be used in place of the published Docker image in your compose file. See Compose Builder nat-bus option to generate compose file for NATS and local dev images.

Packaging

This component is packaged as docker image.

For docker, please refer to the Dockerfile and Docker Compose Builder scripts.

License

Apache-2.0

device-gpio's People

Contributors

bill-mahoney avatar chc69 avatar cloudxxx8 avatar dependabot[bot] avatar ejlee3 avatar ernestojeda avatar farshidtz avatar felixting avatar greystone avatar iain-anderson avatar jackchenjc avatar jim-wang-intel avatar jpwhitemn avatar jumpingliu avatar marcpfuller avatar monicaisher avatar soda480 avatar theonefx avatar tonyespy avatar weichou1229 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

device-gpio's Issues

Remove unused protocol properties from device definitions

๐Ÿš€ Tech Debt

Relevant Package [REQUIRED]

This feature request is for Device Definition files

Description [REQUIRED]

This service doesn't have any protocolo properties, but the device definitions have some properties specified which will confuse end users.

Describe the solution you'd like

Remove the unused/unneeded protocolo properties in the device definitions.

Describe alternatives you've considered

Have you considered any alternative solutions or workarounds?

GPIO value set to zero on read operations

Reading a GPIO value via the REST API sets its value back to 0 / false.

Platform: Raspberry Pi 4 / Ubuntu 20.04 64bits
Driver: sysfs*

Build natively:

$ git describe
v2.0.0-dev.2
$ make build
CGO_ENABLED=1 GO111MODULE=on go build -ldflags "-X github.com/edgexfoundry/device-gpio.Version=0.0.0" -o cmd/device-gpio ./cmd

Supply a vault token:

$ mkdir -p /tmp/edgex/secrets/device-gpio/
$ sudo cp /var/snap/edgexfoundry/current/secrets/device-gpio/secrets-token.json /tmp/edgex/secrets/device-gpio/

Run:

$ cd cmd
$ sudo ./device-gpio 
level=INFO ts=2022-04-01T18:06:50.139803754Z app=device-gpio source=config.go:373 msg="Loaded service configuration from ./res/configuration.toml"
level=INFO ts=2022-04-01T18:06:50.141508792Z app=device-gpio source=secret.go:52 msg="Creating SecretClient"
level=INFO ts=2022-04-01T18:06:50.141571774Z app=device-gpio source=secret.go:59 msg="Reading secret store configuration and authentication token"
level=INFO ts=2022-04-01T18:06:50.141904963Z app=device-gpio source=secret.go:71 msg="Attempting to create secret client"
level=INFO ts=2022-04-01T18:06:50.147615104Z app=device-gpio source=secret.go:76 msg="Created SecretClient"
level=INFO ts=2022-04-01T18:06:50.147725216Z app=device-gpio source=secret.go:81 msg="SecretsFile not set, skipping seeding of service secrets."
level=INFO ts=2022-04-01T18:06:50.147811013Z app=device-gpio source=config.go:510 msg="Using local configuration from file (0 envVars overrides applied)"
level=INFO ts=2022-04-01T18:06:50.147825477Z app=device-gpio source=secrets.go:276 msg="kick off token renewal with interval: 30m0s"
level=INFO ts=2022-04-01T18:06:50.14793533Z app=device-gpio source=httpserver.go:123 msg="Web server starting (localhost:59910)"
level=INFO ts=2022-04-01T18:06:50.148023034Z app=device-gpio source=messaging.go:69 msg="Setting options for secure MessageBus with AuthMode='usernamepassword' and SecretName='redisdb"
level=INFO ts=2022-04-01T18:06:50.152073193Z app=device-gpio source=messaging.go:99 msg="Connected to redis Message Bus @ redis://localhost:6379 publishing on 'edgex/events/device' prefix topic with AuthMode='usernamepassword'"
level=INFO ts=2022-04-01T18:06:50.152349529Z app=device-gpio source=init.go:137 msg="Check core-metadata service's status by ping..."
level=INFO ts=2022-04-01T18:06:50.156037757Z app=device-gpio source=init.go:56 msg="Service clients initialize successful."
level=INFO ts=2022-04-01T18:06:50.156159721Z app=device-gpio source=restrouter.go:47 msg="Registering v2 routes..."
level=INFO ts=2022-04-01T18:06:50.164477929Z app=device-gpio source=driver.go:53 msg="Interface: sysfs"
level=INFO ts=2022-04-01T18:06:50.164634764Z app=device-gpio source=driver.go:54 msg="ChipSelected: 0"
level=INFO ts=2022-04-01T18:06:50.166401674Z app=device-gpio source=service.go:216 msg="device service device-gpio exists, updating it"
level=INFO ts=2022-04-01T18:06:50.170177606Z app=device-gpio source=profiles.go:54 msg="Loading pre-defined profiles from /home/ubuntu/device-gpio/cmd/res/profiles"
level=INFO ts=2022-04-01T18:06:50.173670721Z app=device-gpio source=profiles.go:88 msg="Profile Custom-GPIO-Device exists, using the existing one"
level=INFO ts=2022-04-01T18:06:50.174023836Z app=device-gpio source=devices.go:49 msg="Loading pre-defined devices from /home/ubuntu/device-gpio/cmd/res/devices"
level=INFO ts=2022-04-01T18:06:50.17451486Z app=device-gpio source=devices.go:85 msg="Device GPIO-Device01 exists, using the existing one"
level=INFO ts=2022-04-01T18:06:50.174593861Z app=device-gpio source=autodiscovery.go:33 msg="AutoDiscovery stopped: disabled by configuration"
level=INFO ts=2022-04-01T18:06:50.174647806Z app=device-gpio source=autodiscovery.go:42 msg="AutoDiscovery stopped: ProtocolDiscovery not implemented"
level=INFO ts=2022-04-01T18:06:50.174697492Z app=device-gpio source=message.go:50 msg="Service dependencies resolved..."
level=INFO ts=2022-04-01T18:06:50.174854438Z app=device-gpio source=message.go:51 msg="Starting device-gpio 0.0.0 "
level=INFO ts=2022-04-01T18:06:50.174906569Z app=device-gpio source=message.go:55 msg="device gpio started"
level=INFO ts=2022-04-01T18:06:50.174955217Z app=device-gpio source=message.go:58 msg="Service started in: 36.751223ms"
level=INFO ts=2022-04-01T18:07:14.896777783Z app=device-gpio source=driver.go:61 msg="protocols: map[other:map[Address:device-custom-gpio-01 Port:300]] resource: Power attributes: map[line:17]"
level=INFO ts=2022-04-01T18:07:22.470707344Z app=device-gpio source=driver.go:95 msg="Driver.HandleWriteCommands: protocols: map[other:map[Address:device-custom-gpio-01 Port:300]], resource: Power, attribute: map[line:17], parameters: [DeviceResource: Power, Bool: true]"
level=INFO ts=2022-04-01T18:07:28.820634334Z app=device-gpio source=driver.go:61 msg="protocols: map[other:map[Address:device-custom-gpio-01 Port:300]] resource: Power attributes: map[line:17]"

In another terminal, get and set GPIO 17:

$ cat /sys/class/gpio/gpio17/value
cat: /sys/class/gpio/gpio17/value: No such file or directory

# Read the GPIO via core-command
$ curl http://localhost:59882/api/v2/device/name/GPIO-Device01/Power
{"apiVersion":"v2","statusCode":200,"event":{"apiVersion":"v2","id":"83637eca-5c4c-4046-852b-08cc90850c63","deviceName":"GPIO-Device01","profileName":"Custom-GPIO-Device","sourceName":"Power","origin":1648836435898034344,"readings":[{"id":"d28e2bb8-ee36-4703-8be7-207bdb479b38","origin":1648836435898034344,"deviceName":"GPIO-Device01","resourceName":"Power","profileName":"Custom-GPIO-Device","valueType":"Bool","value":"false"}]}}

# File is created and GPIO value is 0
$ cat /sys/class/gpio/gpio17/value
0

# Set to true
$ curl -X PUT -d '{"Power":"true"}' http://localhost:59882/api/v2/device/name/GPIO-Device01/Power
{"apiVersion":"v2","statusCode":200}

# GPIO value is changed to 1
ubuntu@mars:~$ cat /sys/class/gpio/gpio17/value
1

# core-command reads 0
$ curl http://localhost:59882/api/v2/device/name/GPIO-Device01/Power
{"apiVersion":"v2","statusCode":200,"event":{"apiVersion":"v2","id":"ffbc04ee-0a88-4a18-b260-3fa933ed7f4e","deviceName":"GPIO-Device01","profileName":"Custom-GPIO-Device","sourceName":"Power","origin":1648836448821058616,"readings":[{"id":"e78de76f-4c98-45c0-bad8-a18748eae83a","origin":1648836448821058616,"deviceName":"GPIO-Device01","resourceName":"Power","profileName":"Custom-GPIO-Device","valueType":"Bool","value":"false"}]}}

# GPIO value is set to 0
$ cat /sys/class/gpio/gpio17/value
0

Notes:

  • I could not try the sysdev driver, as I keep getting "using invalid chip" even though I've set it correctly.
  • Same issue with snapped service; see #13

Bump pre-release version to v2

The latest tag is v1.0.1-dev.7 on the development code meant for v2. The version number should increase to indicate we are working towards v2, e.g. v2.0.0-dev.1

compile error

๐Ÿž Bug Report

Affected Services [REQUIRED]

The issue is located in:

github.com/warthog618/gpiod

Is this a regression?

no , the only release version occurs

Description and Minimal Reproduction [REQUIRED]

๐Ÿ”ฅ Exception or Error




1. download the release version zip and unwrap
2. `cd  /path/to/the/folder && make build`
3. occurs this
![image](https://github.com/edgexfoundry/device-gpio/assets/47080137/af69b3fb-924b-498b-b995-7b253043c84c)

๐ŸŒ Your Environment

Deployment Environment:
macos 14.0 of Apple M2 chip MacBookย Air
EdgeX Version [REQUIRED]:
4.0.0

Anything else relevant?
go version go1.20.10 darwin/arm64

Change configuration and device toml files to yaml

๐Ÿš€ Feature Request

Relevant Package [REQUIRED]

This feature request is for configuration and device gpio custom and device gpio led

Description [REQUIRED]

This is a request to convert toml files to yaml and remove toml dependencies

Describe the solution you'd like

If you have a solution in mind, please describe it.

Describe alternatives you've considered

Have you considered any alternative solutions or workarounds?

build: Ignore all go-mods except device-sdk-go

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/device-sdk-go/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

New Dependency Instructions (If applicable)

Line number will overflow when it exceeds 255

Hi

I am using the device-gpio of EdgeX v2.3. I am aware the GPIO line number of the device profile will overflow when the line number exceeds 255.
I am using Dell 3001 gateway, assigned external GPIO from line #330 to #338. This will be truncated into 74 since the original variable type of line is Uint8.

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.