Changeset ac307b2 in mainline for uspace/app/sportdmp/sportdmp.c


Ignore:
Timestamp:
2017-11-25T11:12:23Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
98cb5e0d
Parents:
f571ca49 (diff), 0851a3d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into callcaps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/sportdmp/sportdmp.c

    rf571ca49 rac307b2  
    2727 */
    2828
    29 #include <char_dev_iface.h>
    3029#include <errno.h>
     30#include <io/chardev.h>
    3131#include <io/serial.h>
    3232#include <loc.h>
    3333#include <stdio.h>
     34#include <stdlib.h>
    3435
    3536#define BUF_SIZE 1
     
    4445        sysarg_t baud = 9600;
    4546        service_id_t svc_id;
     47        chardev_t *chardev;
    4648        serial_t *serial;
     49        size_t nread;
    4750
    4851        int arg = 1;
     
    119122        }
    120123
     124        rc = chardev_open(sess, &chardev);
     125        if (rc != EOK) {
     126                fprintf(stderr, "Failed opening character device\n");
     127                return 2;
     128        }
     129
    121130        rc = serial_open(sess, &serial);
    122131        if (rc != EOK) {
     
    138147
    139148        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");
    143155                        break;
    144                 }
    145                 ssize_t i;
    146                 for (i = 0; i < read; i++) {
    147                         printf("%02hhx ", buf[i]);
    148156                }
    149157                fflush(stdout);
     
    152160        free(buf);
    153161        serial_close(serial);
     162        chardev_close(chardev);
    154163        async_hangup(sess);
    155164        return 0;
Note: See TracChangeset for help on using the changeset viewer.