Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 6:0d434f4c83bd
- Parent:
- 5:502371e99bdb
- Child:
- 7:f3ba13c6d56e
--- a/main.cpp Wed Mar 06 09:11:18 2013 +0000
+++ b/main.cpp Wed Mar 06 23:14:11 2013 +0000
@@ -8,6 +8,7 @@
#define WRITE_FUNCTION_MS 1000
+
struct Task {
PortID _id;
int _ratio;
@@ -48,7 +49,7 @@
printf("XBEE: pan id: %d\n\r", xbee.getPanID());
//wireless network
- xbee.init(1, 2);
+ xbee.init(5, 10);
srand(time(0));
@@ -77,12 +78,12 @@
for (int i=0; i<N_TASKS; i++)
vals[i] = -1;
while(1) {
- for (int i=0; i<N_TASKS; i++)
+ for (int i=0; i<N_TASKS; i++) {
if (vals[i]!=task_array[i]->_s->read()) {
vals[i] = task_array[i]->_s->read();
- printf("Read[%d] = %d\n\r", task_array[i]->_id,
- task_array[i]->_s->read());
+ printf("%ld: Read[%d] = %d\n\r", time(0), task_array[i]->_id, task_array[i]->_s->read());
}
+ }
Thread::wait(READ_FUNCTION_MS);
}
}
@@ -94,8 +95,7 @@
for (int i=0; i<N_TASKS; i++)
if (x%(task_array[i]->_ratio)==0) {
task_array[i]->_s->write(task_array[i]->_val++);
- printf("Write[%d] = %d\n\r", task_array[i]->_id,
- task_array[i]->_val);
+ printf("%ld: Write[%d] = %d\n\r", time(0), task_array[i]->_id, task_array[i]->_val);
}
x++;
Thread::wait(WRITE_FUNCTION_MS);