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