Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No EOF on ARM #78

Open
jerbob92 opened this issue Feb 21, 2018 · 3 comments
Open

No EOF on ARM #78

jerbob92 opened this issue Feb 21, 2018 · 3 comments

Comments

@jerbob92
Copy link

I'm using this library on ARM (Raspberry Pi), I never seem to receive an EOF.
When I tested it on my laptop it worked fine. Is there possibly a difference between the two?
(I use github.com/mitchellh/gox to cross-compile)

@xiegeo
Copy link

xiegeo commented Feb 22, 2018

Can you show some minimum code that demo this? Include what you do to trigger EOF, and what hardware you use for serial connection.

I don't test for EOF in my own usage so I'm not sure how it's supposed to work, or how you are using it, but I can try reproducing it on my rpi-3 and I develop in Windows, since I'm interested in knowing and possibly eliminating any inconsistencies.

@amery
Copy link

amery commented May 3, 2018

I'm not getting EOF on intel either

https://gist.github.com/amery/eb19d400faf684fc92f677fed3eb7b86

package main

import (
        "io"
        "log"
        "time"

        "github.com/tarm/serial"
)

func read(buf []byte, f io.Reader, done chan error) {
        log.Println("Read")
        l, err := f.Read(buf)
        log.Println("Read", l, err, buf[:l])
        done <-err
}

func main() {
        tc := serial.Config{
                Name:     "/dev/ttyUSB0",
                Baud:     9600,
                Size:     8,
                Parity:   serial.ParityNone,
                StopBits: serial.Stop1,
        }

        port, err := serial.OpenPort(&tc)
        log.Println("OpenPort", &tc, port, err)

        if err == nil {
                var buf [256]byte

                done := make(chan error, 1)

                go read(buf[:], port, done)

                time.Sleep(time.Second * 2)

                err = port.Close()
                log.Println("Close", err)

                err = <-done
                log.Println("Done", err)
        }
}

but f.Read() never ends

2018/05/03 01:47:13 OpenPort &{/dev/ttyUSB0 9600 0s 8 78 1} &{0xc420096018} <nil>
2018/05/03 01:47:13 Read
2018/05/03 01:47:15 Close <nil>

@xiegeo
Copy link

xiegeo commented May 12, 2018

Thank you @amery, I can reproduce that on rpi with a USB serial device too. I feel that the problem is from the underlining USB driver, since read and close just forward the calls to the file handler, but have not got around to isolating the problem yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants