Changeset 79ae36dd in mainline for uspace/app/tester/hw
- Timestamp:
- 2011-06-08T19:01:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eff68e
- Parents:
- 764d71e
- Location:
- uspace/app/tester/hw
- Files:
-
- 2 edited
-
misc/virtchar1.c (modified) (3 diffs)
-
serial/serial1.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/hw/misc/virtchar1.c
r764d71e r79ae36dd 43 43 #include <str.h> 44 44 #include <vfs/vfs.h> 45 #include <vfs/vfs_sess.h> 45 46 #include <sys/stat.h> 46 47 #include <fcntl.h> … … 66 67 TPRINTF(" ...file handle %d\n", fd); 67 68 68 TPRINTF(" Asking for phone...\n");69 int phone = fd_phone(fd);70 if ( phone < 0) {69 TPRINTF(" Asking for session...\n"); 70 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 71 if (!sess) { 71 72 close(fd); 72 TPRINTF(" ...error: %s\n", str_error( phone));73 return "Failed to get phoneto device";73 TPRINTF(" ...error: %s\n", str_error(errno)); 74 return "Failed to get session to device"; 74 75 } 75 TPRINTF(" ... phone is %d\n", phone);76 TPRINTF(" ...session is %p\n", sess); 76 77 77 78 TPRINTF(" Will try to read...\n"); 78 79 size_t i; 79 80 char buffer[BUFFER_SIZE]; 80 char_dev_read( phone, buffer, BUFFER_SIZE);81 char_dev_read(sess, buffer, BUFFER_SIZE); 81 82 TPRINTF(" ...verifying that we read zeroes only...\n"); 82 83 for (i = 0; i < BUFFER_SIZE; i++) { … … 88 89 89 90 /* Clean-up. */ 90 TPRINTF(" Closing phones and file descriptors\n");91 async_hangup( phone);91 TPRINTF(" Closing session and file descriptor\n"); 92 async_hangup(sess); 92 93 close(fd); 93 94 -
uspace/app/tester/hw/serial/serial1.c
r764d71e 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.
