41,16 → 41,6 |
|
using namespace std; |
|
#define CMPS03_SOFTWARE_REVISION 0x0 |
#define SRF02_SOFTWARE_REVISION 0x0 |
|
#define I2C_SLAVE 0x0703 /* Change slave address */ |
#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ |
#define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ |
/* Attn.: Slave address is 7 or 10 bits */ |
/* This changes the address, even if it */ |
/* is already taken! */ |
|
#define BC_Addr 0x0B |
#define US_Addr 0x70 // 0xE0 in fact |
#define PIC_Addr 0x50 // 0xA0 in fact |
89,7 → 79,7 |
cerr << "Could not open /dev/i2c-0." << endl; |
return -1; |
} |
|
/* |
if (ioctl(file, I2C_SLAVE, BC_Addr) == -1) |
{ |
fprintf(stderr, "Failed to set address to 0x%02x.\n", BC_Addr); |
119,7 → 109,7 |
|
Buf[Len] = 0x00; |
fprintf(stdout, "Board ID is %s.\n", Buf); |
|
*/ |
//!------ US --------------------------------------------------------------------------- |
|
pthread_create(&thread_id, NULL, print_tele, NULL); |
148,6 → 138,10 |
write(file, Buf, 1); |
read(file, Buf, 1); |
ble=Buf[0]; |
|
//!-------- |
printf("Vzdalenost: %u cm Command: %x\n",vzdalenost,ble); |
|
}; |
close(file); |
pthread_join(thread_id, NULL); |