Changes in uspace/app/sportdmp/sportdmp.c [74017ce:c4c6025] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sportdmp/sportdmp.c
r74017ce rc4c6025 27 27 */ 28 28 29 #include <char_dev_iface.h> 29 30 #include <errno.h> 30 #include <io/chardev.h>31 31 #include <io/serial.h> 32 32 #include <loc.h> 33 33 #include <stdio.h> 34 #include <stdlib.h>35 34 36 35 #define BUF_SIZE 1 … … 45 44 sysarg_t baud = 9600; 46 45 service_id_t svc_id; 47 chardev_t *chardev;48 46 serial_t *serial; 49 size_t nread;50 47 51 48 int arg = 1; … … 122 119 } 123 120 124 rc = chardev_open(sess, &chardev);125 if (rc != EOK) {126 fprintf(stderr, "Failed opening character device\n");127 return 2;128 }129 130 121 rc = serial_open(sess, &serial); 131 122 if (rc != EOK) { … … 147 138 148 139 while (true) { 149 rc = chardev_read(chardev, buf, BUF_SIZE, &nread); 150 for (size_t i = 0; i < nread; i++) { 140 ssize_t read = char_dev_read(sess, buf, BUF_SIZE); 141 if (read < 0) { 142 fprintf(stderr, "Failed reading from serial device\n"); 143 break; 144 } 145 ssize_t i; 146 for (i = 0; i < read; i++) { 151 147 printf("%02hhx ", buf[i]); 152 }153 if (rc != EOK) {154 fprintf(stderr, "\nFailed reading from serial device\n");155 break;156 148 } 157 149 fflush(stdout); … … 160 152 free(buf); 161 153 serial_close(serial); 162 chardev_close(chardev);163 154 async_hangup(sess); 164 155 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.