~martin-decky/helenos/rcu

« back to all changes in this revision

Viewing changes to uspace/app/tester/hw/serial/serial1.c

  • Committer: Jiri Svoboda
  • Date: 2012-04-04 17:25:49 UTC
  • Revision ID: jiri@wiwaxia-20120404172549-b0553lkh2bjm9njn
tester/serial1 should not include devman.h

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
#include <sys/types.h>
42
42
#include <async.h>
43
43
#include <ipc/services.h>
44
 
#include <ipc/devman.h>
45
 
#include <devman.h>
 
44
#include <loc.h>
46
45
#include <device/char_dev.h>
47
46
#include <str.h>
48
47
#include <ipc/serial_ctl.h>
70
69
                        return "Unexpected argument error";
71
70
                }
72
71
        
73
 
        devman_handle_t handle;
74
 
        int res = devman_fun_get_handle("/hw/pci0/00:01.0/com1/a", &handle,
75
 
            IPC_FLAG_BLOCKING);
 
72
        service_id_t svc_id;
 
73
        int res = loc_service_get_id("devices/\\hw\\pci0\\00:01.0\\com1\\a",
 
74
            &svc_id, IPC_FLAG_BLOCKING);
76
75
        if (res != EOK)
77
 
                return "Could not get serial device handle";
 
76
                return "Failed getting serial port service ID";
78
77
        
79
 
        async_sess_t *sess = devman_device_connect(EXCHANGE_SERIALIZE, handle,
 
78
        async_sess_t *sess = loc_service_connect(EXCHANGE_SERIALIZE, svc_id,
80
79
            IPC_FLAG_BLOCKING);
81
80
        if (!sess)
82
 
                return "Unable to connect to serial device";
 
81
                return "Failed connecting to serial device";
83
82
        
84
83
        char *buf = (char *) malloc(cnt + 1);
85
84
        if (buf == NULL) {
86
85
                async_hangup(sess);
87
 
                return "Failed to allocate input buffer";
 
86
                return "Failed allocating input buffer";
88
87
        }
89
88
        
90
89
        sysarg_t old_baud;
111
110
        if (EOK != res) {
112
111
                free(buf);
113
112
                async_hangup(sess);
114
 
                return "Failed to set serial communication parameters";
 
113
                return "Failed setting serial communication parameters";
115
114
        }
116
115
        
117
 
        TPRINTF("Trying to read %zu characters from serial device "
118
 
            "(handle=%" PRIun ")\n", cnt, handle);
 
116
        TPRINTF("Trying reading %zu characters from serial device "
 
117
            "(svc_id=%" PRIun ")\n", cnt, svc_id);
119
118
        
120
119
        size_t total = 0;
121
120
        while (total < cnt) {
129
128
                        
130
129
                        free(buf);
131
130
                        async_hangup(sess);
132
 
                        return "Failed read from serial device";
 
131
                        return "Failed reading from serial device";
133
132
                }
134
133
                
135
134
                if ((size_t) read > cnt - total) {
164
163
                                
165
164
                                free(buf);
166
165
                                async_hangup(sess);
167
 
                                return "Failed write to serial device";
 
166
                                return "Failed writing to serial device";
168
167
                        }
169
168
                        
170
169
                        if (written != read) {