mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
rf22: Removed new from examples
Removed new from examples. Client had new w/o delete. These don't need to be pointers. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
parent
2f051a202c
commit
5943dad78c
@ -38,9 +38,9 @@ sig_handler (int signo) {
|
|||||||
int
|
int
|
||||||
main (int argc, char ** argv) {
|
main (int argc, char ** argv) {
|
||||||
// SPI bus 0, CS pin 10, INTR pin 2
|
// SPI bus 0, CS pin 10, INTR pin 2
|
||||||
upm::RF22* rf22 = new upm::RF22 (0, 10, 2);
|
upm::RF22 rf22(0, 10, 2);
|
||||||
|
|
||||||
if (!rf22->init()) {
|
if (!rf22.init()) {
|
||||||
std::cout << "RF22 init failed" << std::endl;
|
std::cout << "RF22 init failed" << std::endl;
|
||||||
return 0x1;
|
return 0x1;
|
||||||
}
|
}
|
||||||
@ -53,13 +53,13 @@ main (int argc, char ** argv) {
|
|||||||
while (amWorking) {
|
while (amWorking) {
|
||||||
std::cout << "Sending to rf22_server" << std::endl;
|
std::cout << "Sending to rf22_server" << std::endl;
|
||||||
// Send a message to rf22_server
|
// Send a message to rf22_server
|
||||||
rf22->send(data, sizeof(data));
|
rf22.send(data, sizeof(data));
|
||||||
rf22->waitPacketSent();
|
rf22.waitPacketSent();
|
||||||
// Now wait for a reply
|
// Now wait for a reply
|
||||||
|
|
||||||
rf22->waitAvailableTimeout(1000000);
|
rf22.waitAvailableTimeout(1000000);
|
||||||
|
|
||||||
if (rf22->recv(buf, &len)) {
|
if (rf22.recv(buf, &len)) {
|
||||||
std::cout << "got response: " << (char*)buf << std::endl;
|
std::cout << "got response: " << (char*)buf << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "!!! NO RESPONSE !!!" << std::endl;
|
std::cout << "!!! NO RESPONSE !!!" << std::endl;
|
||||||
|
@ -38,9 +38,9 @@ sig_handler (int signo) {
|
|||||||
int
|
int
|
||||||
main (int argc, char ** argv) {
|
main (int argc, char ** argv) {
|
||||||
// SPI bus 0, CS pin 10, INTR pin 2
|
// SPI bus 0, CS pin 10, INTR pin 2
|
||||||
upm::RF22* rf22 = new upm::RF22 (0, 10, 2);
|
upm::RF22 rf22(0, 10, 2);
|
||||||
|
|
||||||
if (!rf22->init()) {
|
if (!rf22.init()) {
|
||||||
std::cout << "RF22 init failed" << std::endl;
|
std::cout << "RF22 init failed" << std::endl;
|
||||||
return 0x1;
|
return 0x1;
|
||||||
}
|
}
|
||||||
@ -50,23 +50,22 @@ main (int argc, char ** argv) {
|
|||||||
|
|
||||||
signal (SIGINT, sig_handler);
|
signal (SIGINT, sig_handler);
|
||||||
while (amWorking) {
|
while (amWorking) {
|
||||||
// rf22->waitAvailable();
|
// rf22.waitAvailable();
|
||||||
rf22->waitAvailableTimeout (500);
|
rf22.waitAvailableTimeout (500);
|
||||||
|
|
||||||
// Should be a message for us now
|
// Should be a message for us now
|
||||||
if (rf22->recv(buf, &len)) {
|
if (rf22.recv(buf, &len)) {
|
||||||
std::cout << "got request: " << (char*)buf << std::endl;
|
std::cout << "got request: " << (char*)buf << std::endl;
|
||||||
|
|
||||||
// Send a reply
|
// Send a reply
|
||||||
uint8_t data[] = "And hello back to you";
|
uint8_t data[] = "And hello back to you";
|
||||||
rf22->send(data, sizeof(data));
|
rf22.send(data, sizeof(data));
|
||||||
rf22->waitPacketSent();
|
rf22.waitPacketSent();
|
||||||
} else {
|
} else {
|
||||||
// Do whatever you need.
|
// Do whatever you need.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete rf22;
|
|
||||||
std::cout << "Exit 'rfm22-server'" << std::endl;
|
std::cout << "Exit 'rfm22-server'" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user