Changeset c4c6025 in mainline for uspace/app/tester/hw/serial/serial1.c
- Timestamp:
- 2017-11-21T18:40:27Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 74017ce, d51a0d6, ee44809
- Parents:
- afec1be
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/hw/serial/serial1.c
rafec1be rc4c6025 46 46 #include <char_dev_iface.h> 47 47 #include <str.h> 48 #include <i pc/serial_ctl.h>48 #include <io/serial.h> 49 49 #include "../../tester.h" 50 50 … … 56 56 { 57 57 size_t cnt; 58 serial_t *serial; 58 59 59 60 if (test_argc < 1) … … 79 80 async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF, 80 81 IPC_FLAG_BLOCKING); 81 if ( !sess)82 if (sess == NULL) 82 83 return "Failed connecting to serial device"; 84 85 res = serial_open(sess, &serial); 86 if (res != EOK) 87 return "Failed opening serial port"; 83 88 84 89 char *buf = (char *) malloc(cnt + 1); 85 90 if (buf == NULL) { 91 serial_close(serial); 86 92 async_hangup(sess); 87 93 return "Failed allocating input buffer"; 88 94 } 89 95 90 sysarg_t old_baud; 91 sysarg_t old_par; 92 sysarg_t old_stop; 93 sysarg_t old_word_size; 94 95 async_exch_t *exch = async_exchange_begin(sess); 96 res = async_req_0_4(exch, SERIAL_GET_COM_PROPS, &old_baud, 97 &old_par, &old_word_size, &old_stop); 98 async_exchange_end(exch); 99 96 unsigned old_baud; 97 serial_parity_t old_par; 98 unsigned old_stop; 99 unsigned old_word_size; 100 101 res = serial_get_comm_props(serial, &old_baud, &old_par, 102 &old_word_size, &old_stop); 100 103 if (res != EOK) { 101 104 free(buf); 105 serial_close(serial); 102 106 async_hangup(sess); 103 107 return "Failed to get old serial communication parameters"; 104 108 } 105 109 106 exch = async_exchange_begin(sess); 107 res = async_req_4_0(exch, SERIAL_SET_COM_PROPS, 1200, 108 SERIAL_NO_PARITY, 8, 1); 109 async_exchange_end(exch); 110 110 res = serial_set_comm_props(serial, 1200, SERIAL_NO_PARITY, 8, 1); 111 111 if (EOK != res) { 112 112 free(buf); 113 serial_close(serial); 113 114 async_hangup(sess); 114 115 return "Failed setting serial communication parameters"; … … 123 124 124 125 if (read < 0) { 125 exch = async_exchange_begin(sess); 126 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 126 (void) serial_set_comm_props(serial, old_baud, 127 127 old_par, old_word_size, old_stop); 128 async_exchange_end(exch);129 128 130 129 free(buf); 130 serial_close(serial); 131 131 async_hangup(sess); 132 132 return "Failed reading from serial device"; … … 134 134 135 135 if ((size_t) read > cnt - total) { 136 exch = async_exchange_begin(sess); 137 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 136 (void) serial_set_comm_props(serial, old_baud, 138 137 old_par, old_word_size, old_stop); 139 async_exchange_end(exch);140 138 141 139 free(buf); 140 serial_close(serial); 142 141 async_hangup(sess); 143 142 return "Read more data than expected"; … … 158 157 159 158 if (written < 0) { 160 exch = async_exchange_begin(sess); 161 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 159 (void) serial_set_comm_props(serial, old_baud, 162 160 old_par, old_word_size, old_stop); 163 async_exchange_end(exch);164 161 165 162 free(buf); 163 serial_close(serial); 166 164 async_hangup(sess); 167 165 return "Failed writing to serial device"; … … 169 167 170 168 if (written != read) { 171 exch = async_exchange_begin(sess); 172 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 169 (void) serial_set_comm_props(serial, old_baud, 173 170 old_par, old_word_size, old_stop); 174 async_exchange_end(exch);175 171 176 172 free(buf); 173 serial_close(serial); 177 174 async_hangup(sess); 178 175 return "Written less data than read from serial device"; … … 190 187 ssize_t written = char_dev_write(sess, (void *) EOT, eot_size); 191 188 192 exch = async_exchange_begin(sess); 193 async_req_4_0(exch, SERIAL_SET_COM_PROPS, old_baud, 194 old_par, old_word_size, old_stop); 195 async_exchange_end(exch); 189 (void) serial_set_comm_props(serial, old_baud, old_par, old_word_size, 190 old_stop); 196 191 197 192 free(buf); 193 serial_close(serial); 198 194 async_hangup(sess); 199 195
Note:
See TracChangeset
for help on using the changeset viewer.