On Sun, Oct 26, 2014 at 2:10 AM, Quoc-Viet Nguyen wrote:
I'm learning go by implementing modbus protocol [1]. It is pretty usable but
only tested against a simulator at the moment.
However, I'm facing a problem with detecting data available from serial port
fd.
In order to have a sort of reading timeout, I have to use a silly
loop+sleep:
https://github.com/goburrow/modbus/blob/master/serial_linux.go#L110
And I'm considering to use syscall.Select on the file fd, which is like:
var rfds syscall.FdSet
FD_SET(file.Fd(), rfds)
n, err := syscall.Select(int(file.Fd()) + 1, &rfds, nil, nil, &timeout)
But I'm not sure how to implement FD_SET here. I searched through the forum
but haven't found the answer or any example of using select.
Do we have an alternative way to have a SetReadDeadline for File like Conn
in net package?
I'm learning go by implementing modbus protocol [1]. It is pretty usable but
only tested against a simulator at the moment.
However, I'm facing a problem with detecting data available from serial port
fd.
In order to have a sort of reading timeout, I have to use a silly
loop+sleep:
https://github.com/goburrow/modbus/blob/master/serial_linux.go#L110
And I'm considering to use syscall.Select on the file fd, which is like:
var rfds syscall.FdSet
FD_SET(file.Fd(), rfds)
n, err := syscall.Select(int(file.Fd()) + 1, &rfds, nil, nil, &timeout)
But I'm not sure how to implement FD_SET here. I searched through the forum
but haven't found the answer or any example of using select.
Do we have an alternative way to have a SetReadDeadline for File like Conn
in net package?
does blocking reads and writes the data to a channel. Then other
goroutines can handle the timeout using a Go select statement.
Ian
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.