Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

gpiostream: Stream.Duration() bug #206

Closed
simokawa opened this issue Dec 23, 2017 · 3 comments
Closed

gpiostream: Stream.Duration() bug #206

simokawa opened this issue Dec 23, 2017 · 3 comments
Labels

Comments

@simokawa
Copy link
Contributor

If I understand correctly, Stream.Resolution() is duration for a single bit and Duration() should return for all bits*.
Current implementation uses the count of bytes instead of bits, this looks wrong to me.
https://github.com/google/periph/blob/master/conn/gpio/gpiostream/gpiostream.go#L68
It should be
return b.Res * time.Duration(len(b.Bits)) * 8
Yeah, it is confusing that len(b.Bits) returns number of bytes.

There may be some code assuming this bug.

@maruel
Copy link
Contributor

maruel commented Dec 23, 2017

Yep :(

@maruel maruel added the bug label Dec 23, 2017
@simokawa
Copy link
Contributor Author

Assuming number of bits to be 8*len(b.Bit) may work for most cases but we may want to specify number of bits explicitly in the struct. For example, gpiostream.Program{} could be a loop of 3bit-stream.

@maruel
Copy link
Contributor

maruel commented Sep 20, 2023

Ported to periph/conn#34.

@maruel maruel closed this as completed Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants