Re: [Libphidget-devel] First stab at the 888 ik
Status: Alpha
Brought to you by:
jstrohm
|
From: Tom B. <tb...@ba...> - 2003-07-03 23:08:18
|
On 1 Jul 2003, Jack Strohm wrote: > Ok, I made a few more changed. For those that are CVS impaired I've put > a copy of the latest code at > > http://iris.homeip.net/~jstrohm/libphidget.tgz > > Let me know how much of it works for the 888 ok, as I said off list, digital in and analog in continue to look good. Digital out is not working correctly. The api currently uses a set/clear bit function, but the phidget takes an 8 bit value .... The code below correctly _sets_ a single bit, but doing that resets all 7 other bits. [whoops, I just realized, I'm messing with code that probably is working correctly for the other interface kits??, I guess we need a new function.] enum ELPError phidgetInterfaceKitWrite(struct phidget *phidgetDevice, int index, int value ) { char buffer[4]; // TODO - This doesn't work for the 888 yet, need to // rework some internal data structures to get it working. // isn't this horribly simplistic? don't we need to // maintain a bitmap of the set bits? Either that or pass // the responsibility for that to the application? // afaik, the 8 bits of buffer[0] are the 8 outputs //buffer[0] = index+(value << 3); buffer[0] = value << index; buffer[1] = 0; buffer[2] = 0; buffer[3] = 0; return(phidgetWrite(phidgetDevice,buffer,4)); } all the comments but the TODO are mine. The simplest fix seems to be to maintain a byte containing the expected value in the phidget. If there is a command for querying the current value in the phidget, a better solution would be to query the phidget, then write out the updated bit mask. The best solution would probably be a combination. I think the API would benefit from a command to query value of either the 8 bit register, or the phidget directly. Comments? My apologies if the HID docs tell how to query the phidget, but they are more than a little intimidating :-( I'll go implement a static char register ... -Tom > > -- > Jack Strohm <js...@ja...> > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01 > _______________________________________________ > Libphidget-devel mailing list > Lib...@li... > https://lists.sourceforge.net/lists/listinfo/libphidget-devel > ---------------------------------------------------------------------- tb...@Ba... | Put all your eggs in one basket and http://BareMetal.com/ | WATCH THAT BASKET! web hosting since '95 | - Mark Twain |