Commit 36528902 authored by TMRh20's avatar TMRh20

Change printf to cout in RPi examples

- For some reason, calling printf before cout results in a hang when
using SPIDEV with RPi
- Add fix for spidev per @mtiutiu #146 & #138
parent 07e83623
......@@ -88,7 +88,7 @@ int main(int argc, char** argv){
bool role_ping_out = true, role_pong_back = false;
bool role = role_pong_back;
printf("RF24/examples/GettingStarted/\n");
cout << "RF24/examples/GettingStarted/\n";
// Setup and configure rf radio
radio.begin();
......
......@@ -82,7 +82,7 @@ uint8_t counter = 1; //
int main(int argc, char** argv){
printf("RPi/RF24/examples/gettingstarted_call_response\n");
cout << "RPi/RF24/examples/gettingstarted_call_response\n";
radio.begin();
radio.enableAckPayload(); // Allow optional ack payloads
radio.enableDynamicPayloads();
......
......@@ -79,7 +79,7 @@ int main(int argc, char** argv){
bool role = 0;
// Print preamble:
printf("RF24/examples/pingpair_dyn/\n");
cout << "RF24/examples/pingpair_dyn/\n";
// Setup and configure rf radio
radio.begin();
......
......@@ -79,7 +79,7 @@ int main(int argc, char** argv){
// Print preamble:
printf("RF24/examples/Transfer/\n");
cout << "RF24/examples/Transfer/\n";
radio.begin(); // Setup and configure rf radio
radio.setChannel(1);
......
......@@ -25,7 +25,7 @@
#define _BV(x) (1<<(x))
#define _SPI spi
#undef SERIAL_DEBUG
//#undef SERIAL_DEBUG
#ifdef SERIAL_DEBUG
#define IF_SERIAL_DEBUG(x) ({x;})
#else
......
......@@ -47,8 +47,14 @@ void SPI::begin(int busNo){
void SPI::init()
{
int ret;
if(this->fd > 0) {
close(this->fd);
}
this->fd = open(this->device.c_str(), O_RDWR);
if (this->fd < 0)
if (this->fd < 0)
{
perror("can't open device");
abort();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment