Changeset 1d1f894 in mainline for uspace/app/usb/example.c
- Timestamp:
- 2010-11-03T15:05:41Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d70a463
- Parents:
- af894a21
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/usb/example.c
raf894a21 r1d1f894 82 82 } 83 83 84 static void client_connection(ipc_callid_t iid, ipc_call_t *icall)85 {86 ipc_answer_0(iid, EOK);87 //printf("%s: client connection()\n", NAME);88 89 while (true) {90 ipc_callid_t callid;91 ipc_call_t call;92 int rc;93 void * buffer;94 size_t len;95 96 callid = async_get_call(&call);97 98 switch (IPC_GET_METHOD(call)) {99 case IPC_M_USB_HCD_DATA_SENT:100 printf("%s: >> Data sent over USB (handle %d, outcome %s).\n",101 NAME, IPC_GET_ARG1(call),102 usb_str_transaction_outcome(IPC_GET_ARG2(call)));103 ipc_answer_0(callid, EOK);104 break;105 106 case IPC_M_USB_HCD_DATA_RECEIVED:107 printf("%s: << Data received over USB (handle %d, outcome %s).\n",108 NAME, IPC_GET_ARG1(call),109 usb_str_transaction_outcome(IPC_GET_ARG2(call)));110 if (IPC_GET_ARG2(call) != USB_OUTCOME_OK) {111 ipc_answer_0(callid, EOK);112 break;113 }114 len = IPC_GET_ARG3(call);115 if (len > 0) {116 rc = async_data_write_accept(&buffer, false,117 1, MAX_SIZE_RECEIVE,118 0, &len);119 if (rc != EOK) {120 ipc_answer_0(callid, rc);121 break;122 }123 free(buffer);124 }125 printf("%s: << Received %uB long buffer (handle %d).\n",126 NAME, len, IPC_GET_ARG1(call));127 ipc_answer_0(callid, EOK);128 break;129 130 case IPC_M_PHONE_HUNGUP:131 //printf("%s: hang-up.\n", NAME);132 return;133 134 default:135 printf("%s: method %d called.\n", NAME, IPC_GET_METHOD(call));136 ipc_answer_0(callid, EOK);137 break;138 }139 }140 }141 142 84 static void data_dump(uint8_t *data, size_t len) 143 85 { … … 154 96 int main(int argc, char * argv[]) 155 97 { 156 int hcd_phone = usb_hcd_c reate_phones(DEV_HCD_NAME, client_connection);98 int hcd_phone = usb_hcd_connect(DEV_HCD_NAME); 157 99 if (hcd_phone < 0) { 158 100 printf("%s: Unable to start comunication with HCD at usb://%s (%d: %s).\n", … … 233 175 234 176 fibril_sleep(1); 235 236 #if 0237 int rc;238 239 printf("%s: usb_hcd_transfer_control_write_setup(...)\n", NAME);240 rc = usb_hcd_transfer_control_write_setup(hcd_phone, target,241 &setup_packet, sizeof(setup_packet), NULL);242 if (rc != EOK) {243 printf("%s: failed setting address (%d).\n", NAME, rc);244 return rc;245 }246 247 printf("%s: usb_hcd_transfer_control_write_status(...)\n", NAME);248 rc = usb_hcd_transfer_control_write_status(hcd_phone, target, NULL);249 if (rc != EOK) {250 printf("%s: failed completing control transfer (%d).\n", NAME, rc);251 return rc;252 }253 254 printf("%s: sleeping for a while...\n", NAME);255 fibril_sleep(5);256 #endif257 177 258 178 printf("%s: exiting.\n", NAME);
Note:
See TracChangeset
for help on using the changeset viewer.