Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
i2c communications
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="danimoth" data-source="post: 1035676" data-attributes="member: 151059"><p>Hello to all,</p><p></p><p>I'm trying to get and set the temperature and the fan RPM from my i2c</p><p>microchip (adt7467, from a PowerBook G4).</p><p></p><p>I tried to do all operations with IORegistry, without touching the i2c</p><p>bus, but while read is ok, writing is not (and man page says which</p><p>writing is not generally supported, so I don't worry).</p><p></p><p>Now I'm trying to use directly the I2C bus, and I open the connection</p><p>with this function:</p><p></p><p>CFMutableDictionaryRef dict;</p><p></p><p>if (dict = IOServiceNameMatching("fan")) {</p><p> io_iterator_t iterator = 0;</p><p> io_service_t fan;</p><p> io_name_t name;</p><p> kern_return_t kr;</p><p></p><p> IOServiceGetMatchingServices(kIOMasterPortDefault, dict, &iterator);</p><p></p><p> while ((fan = IOIteratorNext(iterator)) != 0) {</p><p> IORegistryEntryGetName(fan,name);</p><p> if (!strcmp(name,"fan"))</p><p> break;</p><p> }</p><p> IOObjectRelease(iterator);</p><p></p><p> kr = IOI2CInterfaceOpen(fan, 0, &connect);</p><p> if (kr == kIOReturnBadArgument)</p><p> printf("Bad Argument\n",kr);</p><p></p><p>I could reach the last if (I get correctly the dictionary, the</p><p>services, and I could get the service with name "fan") but when I try</p><p>to open it, the result is everytime a kIOReturnBadArgument (connect is</p><p>a IOI2CConnectRef).</p><p>Man pages of I2CInterfaceOpen refer to IOFBCopyI2CInterfaceForBus, but</p><p>I don't know why (and how) use framebuffer when my i2c device is on</p><p>the motherboard. I see PPCI2CInterface, but seems it is private to the</p><p>kernel, and doesn't expose any public API to user-level.</p><p></p><p>What I'm doing wrong?</p><p>There are others API which I doesn't see?</p><p></p><p>Any link or reference is appreciated.</p><p>Many thanks</p></blockquote><p></p>
[QUOTE="danimoth, post: 1035676, member: 151059"] Hello to all, I'm trying to get and set the temperature and the fan RPM from my i2c microchip (adt7467, from a PowerBook G4). I tried to do all operations with IORegistry, without touching the i2c bus, but while read is ok, writing is not (and man page says which writing is not generally supported, so I don't worry). Now I'm trying to use directly the I2C bus, and I open the connection with this function: CFMutableDictionaryRef dict; if (dict = IOServiceNameMatching("fan")) { io_iterator_t iterator = 0; io_service_t fan; io_name_t name; kern_return_t kr; IOServiceGetMatchingServices(kIOMasterPortDefault, dict, &iterator); while ((fan = IOIteratorNext(iterator)) != 0) { IORegistryEntryGetName(fan,name); if (!strcmp(name,"fan")) break; } IOObjectRelease(iterator); kr = IOI2CInterfaceOpen(fan, 0, &connect); if (kr == kIOReturnBadArgument) printf("Bad Argument\n",kr); I could reach the last if (I get correctly the dictionary, the services, and I could get the service with name "fan") but when I try to open it, the result is everytime a kIOReturnBadArgument (connect is a IOI2CConnectRef). Man pages of I2CInterfaceOpen refer to IOFBCopyI2CInterfaceForBus, but I don't know why (and how) use framebuffer when my i2c device is on the motherboard. I see PPCI2CInterface, but seems it is private to the kernel, and doesn't expose any public API to user-level. What I'm doing wrong? There are others API which I doesn't see? Any link or reference is appreciated. Many thanks [/QUOTE]
Verification
Name this item 🌈
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
i2c communications
Top