Added FUSE support #55
29
fuse.go
29
fuse.go
@ -14,35 +14,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
yannickulrich marked this conversation as resolved
Outdated
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Device struct {
|
|
||||||
dev *infinitime.Device
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i Device) HeartRateBytes() ([]byte, error) {
|
|
||||||
v, err := i.dev.HeartRate()
|
|
||||||
return []byte(strconv.Itoa(int(v)) + "\n"), err
|
|
||||||
}
|
|
||||||
func (i Device) BatteryLevelBytes() ([]byte, error) {
|
|
||||||
v, err := i.dev.BatteryLevel()
|
|
||||||
return []byte(strconv.Itoa(int(v)) + "\n"), err
|
|
||||||
}
|
|
||||||
func (i Device) StepCountBytes() ([]byte, error) {
|
|
||||||
v, err := i.dev.StepCount()
|
|
||||||
return []byte(strconv.Itoa(int(v)) + "\n"), err
|
|
||||||
}
|
|
||||||
func (i Device) MotionBytes() ([]byte, error) {
|
|
||||||
v, err := i.dev.Motion()
|
|
||||||
return []byte(strconv.Itoa(int(v.X)) + " " + strconv.Itoa(int(v.Y)) + " " + strconv.Itoa(int(v.Z)) + "\n"), err
|
|
||||||
}
|
|
||||||
func (i Device) AddressBytes() ([]byte, error) {
|
|
||||||
v := i.dev.Address()
|
|
||||||
return []byte(v + "\n"), nil
|
|
||||||
}
|
|
||||||
func (i Device) VersionBytes() ([]byte, error) {
|
|
||||||
v, err := i.dev.Version()
|
|
||||||
return []byte(v + "\n"), err
|
|
||||||
}
|
|
||||||
|
|
||||||
func converterU8(ctx context.Context, in <-chan uint8) <-chan []byte {
|
func converterU8(ctx context.Context, in <-chan uint8) <-chan []byte {
|
||||||
out := make(chan []byte, 2)
|
out := make(chan []byte, 2)
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user
Use
os.MkdirAll
here instead so that it creates parent directories, and handle the error (just return it).This is actually a bit more complicated than that. If the mountpoint already exists, fuse will crash. We also can't delete the mountpoint beforehand (
rm: cannot remove '/tmp/itd/mnt': Transport endpoint is not connected
). The best way to solve this should be calling the unmount function. How would you suggest going about doing this?Yeah, this one is going to be a bit more complicated. The FUSE library does have a different unmount function that you could call before trying to mount the fs, but it's not exported, so we'll need to do a small hack to get access to it anyway. In the
fusefs
package, add a file calledunmount.go
with the following contents:unmount.go
Then, you can simply call that function at the top of
startFUSE
like so:I'll file an issue with the fuse library to export that function once this is merged.
I agree that this should be done. However, this doesn't solve the problem completely because if ITD panics for whatever reason, it won't get run and then the user will get a confusing message. Let me see what the best way would be to call this function on shutdown.
Cool, thank you! I have implemented this 🙂