I'm trying to communicate with display over ddc/ci using MacOS X function IOI2CSendRequest. All works if i just send "set" command, like set brightness. I see that display receive command, because display change brightness.
But when i'm trying to receive reply from display i receive some garbage. What is correct way for send and receive reply with IOI2CSendRequest?
Here is my current code:
memset(&request, 0, sizeof (request));
request.commFlags = 0;
request.sendAddress = addr << 1;
request.sendTransactionType = kIOI2CSimpleTransactionType;
request.sendBuffer = (vm_address_t) package;
request.sendBytes = i;
request.replyAddress = (addr << 1) + 1;
request.replyTransactionType = kIOI2CNoTransactionType;
request.replyBuffer = NULL;
request.replyBytes = 0;
kr = IOI2CSendRequest(Display_, kNilOptions, &request);
mysleep(1000);
memset(&request, 0, sizeof (request));
request.commFlags = 0;
request.sendAddress = addr << 1;
request.sendTransactionType = kIOI2CNoTransactionType;
request.sendBuffer = (vm_address_t)package;
request.sendBytes = 0;
request.replyAddress = (addr << 1) + 1;
request.replyTransactionType = kIOI2CSimpleTransactionType;
request.replyBuffer = (vm_address_t) buf;
request.replyBytes = 127;
memset(buf, 0, request.replyBytes);
kr = IOI2CSendRequest(Display_, kNilOptions, &request);
Both kr and request.result equal to kIOReturnSuccess, but no valid data in buf. Sent command is "51 82 01 10 AC", where is AC is checksum.
OS is 10.6.8 (Snow Leopard)
Any idea what is wrong in this code?