~ubuntu-branches/ubuntu/wily/bluez/wily

« back to all changes in this revision

Viewing changes to tools/csr_bcsp.c

ImportĀ upstreamĀ versionĀ 4.81

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 *
3
3
 *  BlueZ - Bluetooth protocol stack for Linux
4
4
 *
5
 
 *  Copyright (C) 2004-2009  Marcel Holtmann <marcel@holtmann.org>
 
5
 *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
6
6
 *
7
7
 *
8
8
 *  This program is free software; you can redistribute it and/or modify
46
46
static struct ubcsp_packet receive_packet;
47
47
static uint8_t receive_buffer[512];
48
48
 
49
 
int csr_open_bcsp(char *device)
 
49
int csr_open_bcsp(char *device, speed_t bcsp_rate)
50
50
{
51
51
        struct termios ti;
52
52
        uint8_t delay, activity = 0x00;
84
84
        ti.c_cc[VMIN] = 1;
85
85
        ti.c_cc[VTIME] = 0;
86
86
 
87
 
        cfsetospeed(&ti, B38400);
 
87
        cfsetospeed(&ti, bcsp_rate);
88
88
 
89
89
        if (tcsetattr(fd, TCSANOW, &ti) < 0) {
90
90
                fprintf(stderr, "Can't change port settings: %s (%d)\n",
124
124
                if (delay) {
125
125
                        usleep(delay * 100);
126
126
 
127
 
                        if (timeout++ > 100) {
 
127
                        if (timeout++ > 5000) {
128
128
                                fprintf(stderr, "Initialization timed out\n");
129
129
                                return -1;
130
130
                        }
217
217
                if (delay) {
218
218
                        usleep(delay * 100);
219
219
 
220
 
                        if (timeout++ > 100) {
 
220
                        if (timeout++ > 5000) {
221
221
                                fprintf(stderr, "Operation timed out\n");
222
222
                                return -1;
223
223
                        }