Re: notification when device change in /dev
Re: notification when device change in /dev
- Subject: Re: notification when device change in /dev
- From: Roland King <email@hidden>
- Date: Thu, 27 Feb 2014 09:47:53 +0800
That's an idea. Not an Arduino, but not dissimilar, it's a UART mapped through a Segger chip which presents as a USB CDC which the kernel grabs and turns into /dev/cu.usbmodem* which required learning about termios and lots of other things I've not had to think about in 20 years.
Kyle, the IOUSB stuff works too, I have that but find there's a delay before the /dev gets created, a random one, and I haven't yet figured out how to work out what device it gets mapped to, hence I thought I'd go backwards, find devices, and check their properties, but it's a great suggestion.
It might be easier to write a user-space driver for the 2 or 3 control functions the CDC device supports (set baud, set stop bits etc) and grab the bytes from USB directly, in fact I think Apple has an example driver and it's CDC. But I've now strayed from Cocoa once we're beyond fsevents.
On 27 Feb, 2014, at 8:07 am, Graham Cox <email@hidden> wrote:
>
> On 27 Feb 2014, at 10:19 am, Roland King <email@hidden> wrote:
>
>> Is there an NSNotification or some other kind of notification you can subscribe to when there's a change in /dev? I'm dealing with an old USB-serial device which creates a cu/tty when inserted (and removed when removed) and I'd like to get a notification when that happens so I can update UI.
>>
>> I've hunted around the docs but clearly haven't found the right one yet. I wish there were a master list of all system notifications somewhere, would be handy to find them, or rule out that they exist.
>
>
> I don't think there is, but you could use fsevents to watch that directory.
>
> Arduino? I notice that the Arduino IDE notices the addition of cu/tty in /dev when you plug in a board, but then again it only displays that in a menu, so it might just do a scan when it updates its menus.
>
> --Graham
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden