We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
config := &serial.Config{Name: "COM3", Baud: 2400, Parity: 'E', StopBits: 1, ReadTimeout: time.Second * 5} port, err := serial.OpenPort(config) checkErr(err) defer port.Close() n, err := port.Write([]byte("FEFEFEFE68310010111819681104333334333516")) checkErr(err) //read buffer := make([]byte, 1024) n, err = port.Read(buffer) checkErr(err) log.Printf("read:%q", buffer[:n])
The text was updated successfully, but these errors were encountered:
//I added sleep. It's OK. time.Sleep(1 * time.Second) buffer := make([]byte, 1024) n, err = port.Read(buffer) checkErr(err) log.Printf("read:%q", buffer[:n])
I added sleep. It's OK.Is there any other way?
Sorry, something went wrong.
Read in a loop until you got everything. If read repeatedly returns early, add a sleep calculated from expected data length and baud rate.
No branches or pull requests
The text was updated successfully, but these errors were encountered: