Changeset c4c6025 in mainline
- Timestamp:
- 2017-11-21T18:40:27Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 74017ce, d51a0d6, ee44809
- Parents:
- afec1be
- Location:
- uspace
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sportdmp/sportdmp.c
rafec1be rc4c6025 29 29 #include <char_dev_iface.h> 30 30 #include <errno.h> 31 #include <i pc/serial_ctl.h>31 #include <io/serial.h> 32 32 #include <loc.h> 33 33 #include <stdio.h> … … 44 44 sysarg_t baud = 9600; 45 45 service_id_t svc_id; 46 serial_t *serial; 46 47 47 48 int arg = 1; … … 113 114 async_sess_t *sess = loc_service_connect(svc_id, INTERFACE_DDF, 114 115 IPC_FLAG_BLOCKING); 115 if ( !sess) {116 if (sess == NULL) { 116 117 fprintf(stderr, "Failed connecting to service\n"); 118 return 2; 117 119 } 118 120 119 async_exch_t *exch = async_exchange_begin(sess); 120 rc = async_req_4_0(exch, SERIAL_SET_COM_PROPS, baud, 121 SERIAL_NO_PARITY, 8, 1); 122 async_exchange_end(exch); 121 rc = serial_open(sess, &serial); 122 if (rc != EOK) { 123 fprintf(stderr, "Failed opening serial port\n"); 124 return 2; 125 } 123 126 127 rc = serial_set_comm_props(serial, baud, SERIAL_NO_PARITY, 8, 1); 124 128 if (rc != EOK) { 125 129 fprintf(stderr, "Failed setting serial properties\n"); … … 147 151 148 152 free(buf); 153 serial_close(serial); 154 async_hangup(sess); 149 155 return 0; 150 156 } -
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 -
uspace/lib/c/Makefile
rafec1be rc4c6025 118 118 generic/io/kio.c \ 119 119 generic/io/klog.c \ 120 generic/io/serial.c \ 120 121 generic/io/snprintf.c \ 121 122 generic/io/vprintf.c \ -
uspace/srv/hid/isdv4_tablet/isdv4.c
rafec1be rc4c6025 29 29 #include <char_dev_iface.h> 30 30 #include <errno.h> 31 #include <stdbool.h> 32 #include <stdint.h> 31 33 #include <stdlib.h> 32 34 #include <mem.h> -
uspace/srv/hid/isdv4_tablet/isdv4.h
rafec1be rc4c6025 27 27 */ 28 28 29 #ifndef __ISDV4_H__ 30 #define __ISDV4_H__ 29 #ifndef ISDV4_H_ 30 #define ISDV4_H_ 31 32 #include <async.h> 31 33 32 34 typedef struct isdv4_event isdv4_event_t; -
uspace/srv/hid/isdv4_tablet/main.c
rafec1be rc4c6025 27 27 */ 28 28 29 #include < char_dev_iface.h>29 #include <async.h> 30 30 #include <errno.h> 31 #include <ipc/serial_ctl.h> 31 #include <fibril_synch.h> 32 #include <io/serial.h> 33 #include <ipc/mouseev.h> 32 34 #include <loc.h> 35 #include <stddef.h> 33 36 #include <stdio.h> 34 #include <fibril_synch.h>35 #include <abi/ipc/methods.h>36 #include <ipc/mouseev.h>37 #include <inttypes.h>38 37 #include <task.h> 39 38 … … 179 178 sysarg_t baud = 38400; 180 179 service_id_t svc_id; 180 serial_t *serial; 181 181 char *serial_port_name = NULL; 182 182 … … 268 268 if (!sess) { 269 269 fprintf(stderr, "Failed connecting to service\n"); 270 } 271 272 async_exch_t *exch = async_exchange_begin(sess); 273 rc = async_req_4_0(exch, SERIAL_SET_COM_PROPS, baud, 274 SERIAL_NO_PARITY, 8, 1); 275 async_exchange_end(exch); 276 270 return 2; 271 } 272 273 rc = serial_open(sess, &serial); 274 if (rc != EOK) { 275 fprintf(stderr, "Failed opening serial port\n"); 276 return 2; 277 } 278 279 rc = serial_set_comm_props(serial, baud, SERIAL_NO_PARITY, 8, 1); 277 280 if (rc != EOK) { 278 281 fprintf(stderr, "Failed setting serial properties\n");
Note:
See TracChangeset
for help on using the changeset viewer.