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

Reading from Serial Ports #1

Open
danielpi opened this issue Mar 17, 2011 · 6 comments
Open

Reading from Serial Ports #1

danielpi opened this issue Mar 17, 2011 · 6 comments

Comments

@danielpi
Copy link

Hi,

I'm trying to use MAAsyncIO to read from a serial port. I can get a file descriptor for the port using the open() function and then use an instance of MAAsyncReader to run code whenever there is data to be read.

Unfortunately the callback is only fired once when the first lot of data arrives to the serial port. The callback is not fired again even if more data arrives to the serial port.

I suspect this is a problem with the way the serial ports are handled within the operating system.

Kind Regards
Daniel Pink.

@mikeash
Copy link
Owner

mikeash commented Mar 17, 2011

I would suspect the same, unless serial ports need some sort of special handling that I don't know about. Do serial port file descriptors work correctly with select or kqueue?

@danielpi
Copy link
Author

I haven't tried with kqueue but they do work with select. I'm using a
separate thread and select at present. It would be nice to use
dispatch source though as the code is a lot cleaner.

Thanks for your reply
Daniel Pink.

On Fri, Mar 18, 2011 at 02:57, mikeash
reply@reply.github.com
wrote:

I would suspect the same, unless serial ports need some sort of special handling that I don't know about. Do serial port file descriptors work correctly with select or kqueue?

Reply to this email directly or view it on GitHub:
#1 (comment)

@mikeash
Copy link
Owner

mikeash commented Mar 17, 2011

It would be interesting to test it with kqueue as well, as that's what GCD uses internally to implement dispatch sources. If it works with kqueue but not GCD, then it would have to either be a bug in MAAsyncIO (entirely possible) or in GCD (I'm doubtful, but you never know).

@danielpi
Copy link
Author

I can't seem to get it to work with kqueues, though it is not showing
the same symptoms as GCD. Probably due to mistakes on my part. Anyway
moving on for now. Thanks for your suggestions.

Daniel.

On Fri, Mar 18, 2011 at 08:45, mikeash
reply@reply.github.com
wrote:

It would be interesting to test it with kqueue as well, as that's what GCD uses internally to implement dispatch sources. If it works with kqueue but not GCD, then it would have to either be a bug in MAAsyncIO (entirely possible) or in GCD (I'm doubtful, but you never know).

Reply to this email directly or view it on GitHub:
#1 (comment)

@jfro
Copy link

jfro commented Nov 6, 2011

I think this is a problem in GCD on 10.6, at least my dispatch source I created on a file descriptor to a serial port does not fire except the first time there's data. on 10.7 it works just fine, no changes to code.

I'm not using MAAsyncIO but sounds like same problem and probably not MAAsyncIO's fault.

@danielpi
Copy link
Author

danielpi commented Nov 7, 2011

Thanks Jeremy,

I haven't tried my code on Lion yet but I'm very hopeful that what you have found is correct. It did really feel like a bug so I was hopeful that it would be fixed up in an update.

Thanks for checking it out and letting me know.

Daniel Pink.

On 2011-11-07, at 8:57 AM, Jeremy Knope wrote:

I think this is a problem in GCD on 10.6, at least my dispatch source I created on a file descriptor to a serial port does not fire except the first time there's data. on 10.7 it works just fine, no changes to code.

I'm not using MAAsyncIO but sounds like same problem and probably not MAAsyncIO's fault.


Reply to this email directly or view it on GitHub:
#1 (comment)

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