- // register aplayHandle file fd into binder mainloop
- err = sd_event_add_io(afb_daemon_get_event_loop(afbIface->daemon), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext);
- if (err < 0) {
- afb_req_fail_f (request, "register-mainloop", "Cannot hook events to mainloop");
+ async_req_ptr = malloc(sizeof(afb_req));
+ *async_req_ptr = request;
+
+ if (UCSI_I2CWrite( &ucsContextS->ucsiData, /* UCSI_Data_t *pPriv*/
+ node_addr, /* uint16_t targetAddress*/
+ false, /* bool isBurst*/
+ 0u, /* block count */
+ 0x2Au, /* i2c slave address */
+ 0x03E8u, /* timeout 1000 milliseconds */
+ i2c_data_sz, /* uint8_t dataLen */
+ &i2c_data[0], /* uint8_t *pData */
+ &ucs2_writei2c_CB, /* callback*/
+ (void*)async_req_ptr /* callback argument */
+ )) {
+ /* asynchronous command is running */
+ afb_req_addref(request);
+ }
+ else {
+ AFB_NOTICE("i2c write: scheduling command failed");
+ afb_req_fail_f(request, "query-command-queue","command queue overload");
+ free(async_req_ptr);
+ async_req_ptr = NULL;