Changes in uspace/app/tester/hw/serial/serial1.c [8b1e15ac:79ae36dd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/hw/serial/serial1.c
r8b1e15ac r79ae36dd 71 71 } 72 72 73 int res = devman_get_phone(DEVMAN_CLIENT, IPC_FLAG_BLOCKING);74 75 73 devman_handle_t handle; 76 res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,74 int res = devman_device_get_handle("/hw/pci0/00:01.0/com1/a", &handle, 77 75 IPC_FLAG_BLOCKING); 78 76 if (res != EOK) 79 77 return "Could not get serial device handle"; 80 78 81 int phone = devman_device_connect(handle, IPC_FLAG_BLOCKING);82 if (phone < 0) {83 devman_hangup_phone(DEVMAN_CLIENT);79 async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle, 80 IPC_FLAG_BLOCKING); 81 if (!sess) 84 82 return "Unable to connect to serial device"; 85 }86 83 87 84 char *buf = (char *) malloc(cnt + 1); 88 85 if (buf == NULL) { 89 async_hangup(phone); 90 devman_hangup_phone(DEVMAN_CLIENT); 86 async_hangup(sess); 91 87 return "Failed to allocate input buffer"; 92 88 } … … 97 93 sysarg_t old_word_size; 98 94 99 res = async_req_0_4(phone, SERIAL_GET_COM_PROPS, &old_baud, 95 async_exch_t *exch = async_exchange_begin(sess); 96 res = async_req_0_4(exch, SERIAL_GET_COM_PROPS, &old_baud, 100 97 &old_par, &old_word_size, &old_stop); 98 async_exchange_end(exch); 99 101 100 if (res != EOK) { 102 101 free(buf); 103 async_hangup(phone); 104 devman_hangup_phone(DEVMAN_CLIENT); 102 async_hangup(sess); 105 103 return "Failed to get old serial communication parameters"; 106 104 } 107 105 108 res = async_req_4_0(phone, SERIAL_SET_COM_PROPS, 1200, 106 exch = async_exchange_begin(sess); 107 res = async_req_4_0(exch, SERIAL_SET_COM_PROPS, 1200, 109 108 SERIAL_NO_PARITY, 8, 1); 109 async_exchange_end(exch); 110 110 111 if (EOK != res) { 111 112 free(buf); 112 async_hangup(phone); 113 devman_hangup_phone(DEVMAN_CLIENT); 113 async_hangup(sess); 114 114 return "Failed to set serial communication parameters"; 115 115 } … … 120 120 size_t total = 0; 121 121 while (total < cnt) { 122 ssize_t read = char_dev_read( phone, buf, cnt - total);122 ssize_t read = char_dev_read(sess, buf, cnt - total); 123 123 124 124 if (read < 0) { 125 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 125 exch = async_exchange_begin(sess); 126 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 126 127 old_par, old_word_size, old_stop); 128 async_exchange_end(exch); 129 127 130 free(buf); 128 async_hangup(phone); 129 devman_hangup_phone(DEVMAN_CLIENT); 131 async_hangup(sess); 130 132 return "Failed read from serial device"; 131 133 } 132 134 133 135 if ((size_t) read > cnt - total) { 134 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 136 exch = async_exchange_begin(sess); 137 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 135 138 old_par, old_word_size, old_stop); 139 async_exchange_end(exch); 140 136 141 free(buf); 137 async_hangup(phone); 138 devman_hangup_phone(DEVMAN_CLIENT); 142 async_hangup(sess); 139 143 return "Read more data than expected"; 140 144 } … … 151 155 * direction of data transfer. 152 156 */ 153 ssize_t written = char_dev_write( phone, buf, read);157 ssize_t written = char_dev_write(sess, buf, read); 154 158 155 159 if (written < 0) { 156 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 160 exch = async_exchange_begin(sess); 161 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 157 162 old_par, old_word_size, old_stop); 163 async_exchange_end(exch); 164 158 165 free(buf); 159 async_hangup(phone); 160 devman_hangup_phone(DEVMAN_CLIENT); 166 async_hangup(sess); 161 167 return "Failed write to serial device"; 162 168 } 163 169 164 170 if (written != read) { 165 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 171 exch = async_exchange_begin(sess); 172 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 166 173 old_par, old_word_size, old_stop); 174 async_exchange_end(exch); 175 167 176 free(buf); 168 async_hangup(phone); 169 devman_hangup_phone(DEVMAN_CLIENT); 177 async_hangup(sess); 170 178 return "Written less data than read from serial device"; 171 179 } … … 180 188 181 189 size_t eot_size = str_size(EOT); 182 ssize_t written = char_dev_write(phone, (void *) EOT, eot_size); 183 184 async_req_4_0(phone, SERIAL_SET_COM_PROPS, old_baud, 190 ssize_t written = char_dev_write(sess, (void *) EOT, eot_size); 191 192 exch = async_exchange_begin(sess); 193 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 185 194 old_par, old_word_size, old_stop); 195 async_exchange_end(exch); 196 186 197 free(buf); 187 async_hangup(phone); 188 devman_hangup_phone(DEVMAN_CLIENT); 198 async_hangup(sess); 189 199 190 200 if (written < 0)
Note:
See TracChangeset
for help on using the changeset viewer.