Changeset 9f1328cd in mainline


Ignore:
Timestamp:
2012-04-03T15:01:31Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d73a56d
Parents:
aeef318
Message:

date: try to connect and read from the device

File:
1 edited

Legend:

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

    raeef318 r9f1328cd  
    3333#include <errno.h>
    3434#include <loc.h>
     35#include <time.h>
    3536
    3637#define NAME   "date"
     
    4546        char *svc_name = NULL;
    4647        char *devpath;
     48        devman_handle_t devh;
     49        struct tm t;
    4750
    4851        /* Get the id of the clock category */
     
    8891        printf("Found device %s\n", devpath);
    8992
     93        /* Get the device's handle */
     94        rc = devman_fun_get_handle("/hw/pci0/00:01.0/cmos-rtc/a", &devh, IPC_FLAG_BLOCKING);
     95        if (rc != EOK) {
     96                printf(NAME ": Cannot open the device\n");
     97                goto exit;
     98        }
     99
     100        printf("OPEN!\n");
     101
     102        /* Now connect to the device */
     103        async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE,
     104            devh, IPC_FLAG_BLOCKING);
     105        if (!sess) {
     106                printf(NAME ": Cannot connect to the device\n");
     107                goto exit;
     108        }
     109
     110        printf("CONNECTED!\n");
     111
     112        /* Read the current date */
     113        rc = clock_dev_time_get(sess, &t);
     114        if (rc != EOK) {
     115                printf(NAME ": Cannot read the current time\n");
     116                goto exit;
     117        }
     118
     119        printf("SUCCESS!\n");
     120        fflush(stdout);
     121
    90122exit:
    91123        free(svc_name);
Note: See TracChangeset for help on using the changeset viewer.