Code Monkey home page Code Monkey logo

Comments (9)

maruel avatar maruel commented on June 15, 2024 1

See https://periph.io/x/periph/experimental/host/netlink

from periph.

bh90210 avatar bh90210 commented on June 15, 2024 1

hi all,

I had the same issue and since I figured it out I thought of sharing an example here.

EDIT: I got the masterID (netlink.New(001)) by running lsusb

package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"
	"time"

	"periph.io/x/periph/devices/ds18b20"
	"periph.io/x/periph/experimental/host/netlink"
	"periph.io/x/periph/host"
)

func main() {
	host.Init()

	// get 1wire bus
	oneBus, _ := netlink.New(001)

	// get 1wire address
	addr, _ := oneBus.Search(false)

	// init ds18b20
	sensor, _ := ds18b20.New(oneBus, addr[0], 10)

	ds18b20.ConvertAll(oneBus, 10)
	temp, _ := sensor.LastTemp()

	fmt.Println(temp)
}

EDIT2: and if I am not mistaken since we are using "periph.io/x/periph/experimental/host/netlink" I don't think "periph.io/x/periph/conn/onewire" will work. panic: interface conversion: *netlink.OneWire is not onewire.Pins: missing method Q

from periph.

cgossain avatar cgossain commented on June 15, 2024 1

Hi all,

I had the same issue. The answer posted by bh90210 above really helped me out!

However, I just wanted to post an updated implementation that references the packages at the new locations.

The following example simply prints the discovered 1-wire devices.

package main

import (
	"fmt"
	"log"

	"periph.io/x/host/v3"
	"periph.io/x/host/v3/netlink"
)

func main() {
	// make sure periph is initialized
	state, err := host.Init()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("Loaded: ", state.Loaded)
	fmt.Println("Skipped: ", state.Skipped)
	fmt.Println("Failed: ", state.Failed)

	// get the 1-wire bus (via Netlink)
	w1, err := netlink.New(001)
	if err != nil {
		log.Fatal(err)
	}
        defer w1.Close()

	// get 1-wire addresses
	addrs, err := w1.Search(false)
	if err != nil {
		log.Fatal(err)
	}

	// print the 1-wire device addresses
	for i, adr := range addrs {
		fmt.Println(i, adr)
	}
}

from periph.

lclslsls avatar lclslsls commented on June 15, 2024

I swa the link
it seems i used the wrong method
but by this link i cannt find something like testcode or democode
i didnot now how to use it
is some where has democode?

from periph.

maruel avatar maruel commented on June 15, 2024

You'll have to ask the code authors, as I personally didn't work on this code. #406

from periph.

lclslsls avatar lclslsls commented on June 15, 2024

but why the onewire test code didnot work
how can i fix this
the spi is work perfect

from periph.

maruel avatar maruel commented on June 15, 2024

I can't parse your question.

I said exactly what to do, you'll have to ask the code authors. I said explicitly I did not work on this code, I never used it.

from periph.

rolandjitsu avatar rolandjitsu commented on June 15, 2024

I've actually seen the same error when using the serial package. Couldn't figure out why though. But from the docs:

At this point, it is available for use to everyone but it is not loaded by default by host.Init().

If that's the case, I wonder how do we init experimental drivers 🤔

from periph.

maruel avatar maruel commented on June 15, 2024

The code was migrated to periph.io/x/host/v3/netlink. If you want to contribute please file a PR or an issue on https://github.com/periph/host.

from periph.

Related Issues (20)

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.