ipc demo
This commit is contained in:
@@ -52,27 +52,35 @@ extern "C" void main() {
|
|||||||
write(1, text, sizeof(text), 0, (int)id);
|
write(1, text, sizeof(text), 0, (int)id);
|
||||||
|
|
||||||
uint8_t cnt = 0;
|
uint8_t cnt = 0;
|
||||||
for (unsigned i = 1;; ++i) {
|
for (uint8_t i = 1;; ++i) {
|
||||||
if(i%10 == 0){
|
|
||||||
if(id == 2){
|
|
||||||
send(4, text, strlen(text), text, 15);
|
|
||||||
write(1, text, strlen(text), 25, (int)id);
|
|
||||||
}
|
|
||||||
if(id == 4){
|
|
||||||
char blubb[10];
|
|
||||||
if(receive(blubb, 20)){
|
|
||||||
write(1, blubb, strlen(blubb), 25, (int)id);
|
|
||||||
}
|
|
||||||
reply("toast ", 11);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//counter to see app running
|
//counter to see app running
|
||||||
cnt=(cnt+1)%100;
|
cnt=(cnt+1)%100;
|
||||||
char buf[12];
|
char buf[32];
|
||||||
char* msg = itoa(cnt,buf);
|
char* msg = itoa(cnt,buf);
|
||||||
write(1, msg, strlen(msg), 6, (int)id);
|
write(1, msg, strlen(msg), 6, (int)id);
|
||||||
|
|
||||||
|
//test ipc
|
||||||
|
if((i+50)%100 == 0){
|
||||||
|
if(id == 2){
|
||||||
|
char txt[] = "toastbrot ";
|
||||||
|
itoa(cnt, &txt[1]);
|
||||||
|
write(2, "send\n", 5);
|
||||||
|
send(4, txt, strlen(txt), txt, 15);
|
||||||
|
write(1, txt, strlen(txt), 25, (int)id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(i%100 == 0){
|
||||||
|
if(id == 4){
|
||||||
|
char blubb[20];
|
||||||
|
if(receive(blubb, sizeof(blubb))){
|
||||||
|
write(1, blubb, strlen(blubb), 25, (int)id);
|
||||||
|
write(2, "reply\n", 6);
|
||||||
|
itoa(cnt, &blubb[1]);
|
||||||
|
reply(blubb, sizeof(blubb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// test map/unmap and print ptr
|
// test map/unmap and print ptr
|
||||||
void* ptr= map(4096);
|
void* ptr= map(4096);
|
||||||
uint16_t* val = ((uint16_t*)ptr);
|
uint16_t* val = ((uint16_t*)ptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user