Skip to content

Commit

Permalink
Change printf to cout in RPi examples
Browse files Browse the repository at this point in the history
- For some reason, calling printf before cout results in a hang when
using SPIDEV with RPi
- Add fix for spidev per @mtiutiu #146 & #138
  • Loading branch information
TMRh20 committed Oct 31, 2015
1 parent 07e8362 commit 3652890
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples_RPi/gettingstarted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples_RPi/gettingstarted_call_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples_RPi/pingpair_dyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples_RPi/transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion utility/BBB/RF24_arch_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion utility/BBB/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3652890

Please sign in to comment.