Skip to content

Commit 3652890

Browse files
committed
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
1 parent 07e8362 commit 3652890

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

examples_RPi/gettingstarted.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int main(int argc, char** argv){
8888
bool role_ping_out = true, role_pong_back = false;
8989
bool role = role_pong_back;
9090

91-
printf("RF24/examples/GettingStarted/\n");
91+
cout << "RF24/examples/GettingStarted/\n";
9292

9393
// Setup and configure rf radio
9494
radio.begin();

examples_RPi/gettingstarted_call_response.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ uint8_t counter = 1; //
8282
int main(int argc, char** argv){
8383

8484

85-
printf("RPi/RF24/examples/gettingstarted_call_response\n");
85+
cout << "RPi/RF24/examples/gettingstarted_call_response\n";
8686
radio.begin();
8787
radio.enableAckPayload(); // Allow optional ack payloads
8888
radio.enableDynamicPayloads();

examples_RPi/pingpair_dyn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int main(int argc, char** argv){
7979
bool role = 0;
8080

8181
// Print preamble:
82-
printf("RF24/examples/pingpair_dyn/\n");
82+
cout << "RF24/examples/pingpair_dyn/\n";
8383

8484
// Setup and configure rf radio
8585
radio.begin();

examples_RPi/transfer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int main(int argc, char** argv){
7979

8080
// Print preamble:
8181

82-
printf("RF24/examples/Transfer/\n");
82+
cout << "RF24/examples/Transfer/\n";
8383

8484
radio.begin(); // Setup and configure rf radio
8585
radio.setChannel(1);

utility/BBB/RF24_arch_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define _BV(x) (1<<(x))
2626
#define _SPI spi
2727

28-
#undef SERIAL_DEBUG
28+
//#undef SERIAL_DEBUG
2929
#ifdef SERIAL_DEBUG
3030
#define IF_SERIAL_DEBUG(x) ({x;})
3131
#else

utility/BBB/spi.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ void SPI::begin(int busNo){
4747
void SPI::init()
4848
{
4949
int ret;
50+
51+
if(this->fd > 0) {
52+
close(this->fd);
53+
}
54+
5055
this->fd = open(this->device.c_str(), O_RDWR);
51-
if (this->fd < 0)
56+
57+
if (this->fd < 0)
5258
{
5359
perror("can't open device");
5460
abort();

0 commit comments

Comments
 (0)