Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Good form for opening/writing/closing



Hi all,
I was able to modify USBSimpleExample to get it to talk to a LabJack UE9 data acquisition device. Once I get the device, interface and pipes set up, I would like to be able to just read and write to the Labjack, then close up shop when I'm done. USBSimpleExample gets things set up with a handleDevice function calling a handleInterface function calling a handlePipes function, at which point I'm all set to write and read to the LabJack.


All I really want to do at this point is write a writeRead function so I can access the LabJack from some Cocoa classes. I suppose I could just put the low level device/interface/pipe setup in the main.m before calling NSApplication and then close stuff out after NSApplication is done, but I bet if the LabJack is unplugged while NSApplication is running things will barf. This would probably work but the unplug thing bothers me. The other way would be to put Cocoa wrappers around and create open and close methods for device/interface/pipe stuff so I could call all this stuff from higher up. Somewhere in between, I'm wondering, is a one stop shop where the writeRead is one monolithic fxn where the device is found, interface and pipes are opened, write and read are performed,everything is closed up and the device released. The main downside to this I suspect is it carries unnecessary overhead of open/close each time. Maybe not a big deal, though.

This is a style question, I guess, but before I go wasting my time on a bad approach, I was wondering what you folks thought.

Thanks,
	Dave

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.