Changeset 74017ce in mainline for uspace/app/sportdmp/sportdmp.c
- Timestamp:
- 2017-11-22T17:36:54Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7a6065c
- Parents:
- c4c6025
- git-author:
- Jiri Svoboda <jiri@…> (2017-11-22 15:53:34)
- git-committer:
- Jiri Svoboda <jiri@…> (2017-11-22 17:36:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/sportdmp/sportdmp.c
rc4c6025 r74017ce 27 27 */ 28 28 29 #include <char_dev_iface.h>30 29 #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> 34 35 35 36 #define BUF_SIZE 1 … … 44 45 sysarg_t baud = 9600; 45 46 service_id_t svc_id; 47 chardev_t *chardev; 46 48 serial_t *serial; 49 size_t nread; 47 50 48 51 int arg = 1; … … 119 122 } 120 123 124 rc = chardev_open(sess, &chardev); 125 if (rc != EOK) { 126 fprintf(stderr, "Failed opening character device\n"); 127 return 2; 128 } 129 121 130 rc = serial_open(sess, &serial); 122 131 if (rc != EOK) { … … 138 147 139 148 while (true) { 140 ssize_t read = char_dev_read(sess, buf, BUF_SIZE); 141 if (read < 0) { 142 fprintf(stderr, "Failed reading from serial device\n"); 149 rc = chardev_read(chardev, buf, BUF_SIZE, &nread); 150 for (size_t i = 0; i < nread; i++) { 151 printf("%02hhx ", buf[i]); 152 } 153 if (rc != EOK) { 154 fprintf(stderr, "\nFailed reading from serial device\n"); 143 155 break; 144 }145 ssize_t i;146 for (i = 0; i < read; i++) {147 printf("%02hhx ", buf[i]);148 156 } 149 157 fflush(stdout); … … 152 160 free(buf); 153 161 serial_close(serial); 162 chardev_close(chardev); 154 163 async_hangup(sess); 155 164 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.