Comments (9)
See https://periph.io/x/periph/experimental/host/netlink
from periph.
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.
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.
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.
You'll have to ask the code authors, as I personally didn't work on this code. #406
from periph.
but why the onewire test code didnot work
how can i fix this
the spi is work perfect
from periph.
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.
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.
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)
- [Question] How do I set a pin to alt0? HOT 6
- All pins are exported during bcm283x Init HOT 3
- Support for firmata HOT 2
- gpio-read: bcm283x-gpio (GPIO7): pull cannot be used when subsystem gpiomem not initialized. HOT 21
- Go get fetches v3.4.0 if using go modules HOT 3
- Support for BME680 HOT 3
- Halt() does not unblock WaitForEdge() HOT 3
- Feature SSD1322 HOT 5
- mfrc522 constantly returns "IRQ error" after first read HOT 11
- spi to slow HOT 5
- Omega2: declare headers HOT 3
- Experimental serial package doesn't export essential func HOT 7
- Unable to set GPIO pin pull on Raspberry Pi 4 HOT 19
- MFRC522 hang on WaitForEdge HOT 2
- HX711: unstable readings and reading before data is ready HOT 2
- spi: rename MISO/MOSI to COPI/CIPO HOT 2
- I2C documentation not clear on read/write operation HOT 2
- MFRC522 - Problem reading Tag HOT 3
- pmem example code incorrect HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from periph.