FAQ
Hi everyone,

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?

Thank you
--
qvn

[1] https://github.com/goburrow/modbus

--
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.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 28 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedOct 26, '14 at 9:10a
activeOct 27, '14 at 7:01p
posts28
users6
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase