Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Writing Drivers for Backup Battery device.

Writing Drivers for Backup Battery device.
Thread Tools
Forum Regular
Join Date: Apr 2002
Location: Canada
Status: Offline
Reply With Quote
Jan 4, 2004, 04:29 AM
 
I bought this Backup battery/Power Regulator and it can be connected through USB to the computer to shutdown the computer in case of a power failur.

No drivers are available for mac. So I thought I could program my own.

How hard could that be to write somekind of daemon and how can I do it?

Thanks!
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 4, 2004, 02:51 PM
 
How hard? Depends on what the daemon has to do. Writing a daemon that does nothing is trivial. Read the man pages on fork and execv.
     
Bi@tch  (op)
Forum Regular
Join Date: Apr 2002
Location: Canada
Status: Offline
Reply With Quote
Jan 5, 2004, 09:35 AM
 
Lets say a Daemon that detects the signal sent by the backup battery and launches an Apple Script?
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 5, 2004, 12:31 PM
 
Originally posted by Bi@tch:
Lets say a Daemon that detects the signal sent by the backup battery and launches an Apple Script?
"signal"? What is the nature of this "signal" that you speak of?

Launching an AppleScript from a daemon would involve fork()ing again and then you could either execv() your own tool to call the OSA API or just execv() /usr/bin/osascript

So, relatively trivial.
     
Bi@tch  (op)
Forum Regular
Join Date: Apr 2002
Location: Canada
Status: Offline
Reply With Quote
Jan 5, 2004, 10:27 PM
 
Well the device is connected to the USB port so...it must send some sort of code right?
     
Senior User
Join Date: Aug 2002
Location: Oxford, England
Status: Offline
Reply With Quote
Jan 7, 2004, 05:16 PM
 
I think your trivialising the process of creating a device driver, however I have the following suggestion.

Check Apples Developer site for the 'USBUPSMonitor' sample code, found here:
http://developer.apple.com/samplecod...UPSMonitor.htm

Download, read instructions and compile - providing your power device is USB Power Class-compatible you might be lucky and find it works with your power device. On the other hand it might not work - in this case you have a source code starting point to work from demonstrating how to use daemons, usb interaction, shutting down system etc.

Perhaps there is an open-source unix driver for your particular power device, search sourceforge.net to find out - this would help you.

I'd also suggest you read through the info on apple's developer site about USB devices and device drivers and perhaps buy a book or two.
Luke
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:37 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2