Jonathan Jones
/
Radios
Radio Structures in OOP
Diff: main.cpp
- Revision:
- 4:989d51f3e6ef
- Parent:
- 3:dc7e9c6bc26c
- Child:
- 5:146523a0d1f4
--- a/main.cpp Sat Jan 03 04:35:32 2015 +0000 +++ b/main.cpp Sat Jan 03 11:04:31 2015 +0000 @@ -11,7 +11,7 @@ DigitalOut led4(LED4); // Dummy function -void primary_radio_rx_handle(void const *arg) +void primary_radio_rx_handle(void) { led3 != led3; } @@ -60,12 +60,12 @@ // Create a Communication Module Object CommModule comm; - //comm.TxHandler((CommLink*)&radio_900, &CommLink::sendPacket, 8); - comm.TxHandler(primary_radio_tx_handle, 8); - + comm.TxHandler((CommLink*)&radio_900, &CommLink::sendPacket, 8); + comm.RxHandler(primary_radio_rx_handle, 8); + comm.openSocket(8); // Open a socket for the Communication Module. Give it a port number and a function to call when a packet of that port number is received - comm.openSocket((CommLink*)&radio_900, 8, primary_radio_rx_handle); + //comm.openSocket((CommLink*)&radio_900, primary_radio_rx_handle, 8); led3 = 1; // Create a dummy packet that is set to send out from socket connection 8 @@ -81,34 +81,34 @@ // Test sending a packet on a port that has not been setup yet dummy_packet.port = 7; comm.send(dummy_packet); - - comm.TxHandler(primary_radio_tx_handle, 7); - comm.openSocket((CommLink*)&radio_900, 7, primary_radio_rx_handle); + //comm.TxHandler(primary_radio_tx_handle, 7); + //comm.openSocket(&radio_900, primary_radio_rx_handle, 7); // Enable watchdog timer //Watchdog watchdog; //watchdog.set(RJ_WATCHDOG_TIMER_VALUE); + + radio_900.triggerReceive(); led2 = 0; + if(false) { + for (int i=1; i<=1000000; i*=10) { + std::printf("Itterations: %u\r\n", i); + Timer t; + t.start(); - for (int i=1; i<=10000000; i*=10) { - std::printf("Itterations: %u\r\n", i); - Timer t; - t.start(); - - led2 = 1; - - for(int j=0; j<i; j++) { - comm.send(dummy_packet); - //osDelay(2); + for(int j=0; j<i; j++) { + comm.send(dummy_packet); + osDelay(1); + } + + t.stop(); + std::printf("Timer Reading: %uus (%.5fs)\r\n\r\n", t.read_us(), t.read()); } - - led2 = 0; + } - t.stop(); - std::printf("Timer Reading: %uus\r\n", t.read_us()); - } + led2 = 1; std::printf("Done\r\n");