Subversion Repositories svnkaklik

Rev

Rev 365 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 365 Rev 366
Line 39... Line 39...
39
#include <fcntl.h>
39
#include <fcntl.h>
40
 
40
 
41
 
41
 
42
using namespace std;
42
using namespace std;
43
 
43
 
44
#define CMPS03_SOFTWARE_REVISION 0x0
-
 
45
#define SRF02_SOFTWARE_REVISION 0x0
-
 
46
 
-
 
47
#define I2C_SLAVE	0x0703	/* Change slave address			*/
-
 
48
#define I2C_RDWR	0x0707	/* Combined R/W transfer (one stop only)*/
-
 
49
#define I2C_SLAVE_FORCE	0x0706	/* Change slave address			*/
-
 
50
				/* Attn.: Slave address is 7 or 10 bits */
-
 
51
				/* This changes the address, even if it */
-
 
52
				/* is already taken!	*/
-
 
53
 
-
 
54
#define BC_Addr	    0x0B
44
#define BC_Addr	    0x0B
55
#define US_Addr	    0x70 // 0xE0 in fact
45
#define US_Addr	    0x70 // 0xE0 in fact
56
#define PIC_Addr	0x50 // 0xA0 in fact
46
#define PIC_Addr	0x50 // 0xA0 in fact
57
 
47
 
58
char vystup[30];
48
char vystup[30];
Line 87... Line 77...
87
	if (file < 0)
77
	if (file < 0)
88
	{
78
	{
89
		cerr << "Could not open /dev/i2c-0." << endl;
79
		cerr << "Could not open /dev/i2c-0." << endl;
90
		return -1;
80
		return -1;
91
	}
81
	}
92
 
82
/*
93
	if (ioctl(file, I2C_SLAVE, BC_Addr) == -1)
83
	if (ioctl(file, I2C_SLAVE, BC_Addr) == -1)
94
	{
84
	{
95
		fprintf(stderr, "Failed to set address to 0x%02x.\n", BC_Addr);
85
		fprintf(stderr, "Failed to set address to 0x%02x.\n", BC_Addr);
96
		DoExit(-2);
86
		DoExit(-2);
97
	}
87
	}
Line 117... Line 107...
117
    }
107
    }
118
 
108
 
119
 
109
 
120
    Buf[Len] = 0x00;
110
    Buf[Len] = 0x00;
121
    fprintf(stdout, "Board ID is %s.\n", Buf);
111
    fprintf(stdout, "Board ID is %s.\n", Buf);
122
 
112
*/
123
//!------ US ---------------------------------------------------------------------------
113
//!------ US ---------------------------------------------------------------------------
124
 
114
 
125
    pthread_create(&thread_id, NULL, print_tele, NULL);
115
    pthread_create(&thread_id, NULL, print_tele, NULL);
126
 
116
 
127
    while(true)
117
    while(true)
Line 146... Line 136...
146
        }
136
        }
147
        Buf[0]=command;
137
        Buf[0]=command;
148
        write(file, Buf, 1);
138
        write(file, Buf, 1);
149
        read(file, Buf, 1);
139
        read(file, Buf, 1);
150
        ble=Buf[0];
140
        ble=Buf[0];
-
 
141
 
-
 
142
//!--------
-
 
143
printf("Vzdalenost: %u cm Command: %x\n",vzdalenost,ble);
-
 
144
 
151
    };
145
    };
152
	close(file);
146
	close(file);
153
    pthread_join(thread_id, NULL);
147
    pthread_join(thread_id, NULL);
154
    fclose(pRouraO);
148
    fclose(pRouraO);
155
 
149