Re: How to do a blocking read from a serial device?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Jul 11, 2006, at 12:04 PM, darwin-dev-request@lists.apple.com wrote: Read(2) will block if there is no data so there's no need to sleep. Using select(2) is one way to go about it but with only one file descriptor/socket, it seems pointless to me. Select(2) makes timeout handling (mandatory for disconnectable devices such as those attached by USB or serial interfaces) much simpler. = Mike _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... On Jul 12, 2006, at 12:02 PM, darwin-dev-request@lists.apple.com wrote: On Jul 11, 2006, at 12:11 PM, Michael Smith wrote: Shouldn't that return -1 or 0? USB device removal can usually be detected and the device will typically be torn down, yes. Serial device removal is much more problematic; there is no reliable way to know that your device has been unplugged, other than that it fails to respond in the expected fashion. This email sent to site_archiver@lists.apple.com
participants (1)
-
Michael Smith