#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "RHexCom.hh"
#define MAILBOX_ID 100
struct MailStruct {
int a, b;
unsigned char c;
};
int main(int argc, char** argv)
{
if (argc != 2) {
fprintf(stderr, "Usage: mailbox <port>\n");
exit(-1);
}
unsigned short port = atoi(argv[1]);
CommManager* mgr = new CommManager(port);
Mailbox* box = mgr->createMailbox(sizeof(MailStruct), MAILBOX_ID);
while (1) {
bool new_data = box->newMail();
Message* msg = box->getData();
MailStruct* dest= (MailStruct*) msg->getData();
printf("Received %d %d %d %d\n", (int) new_data,
dest->a, dest->b, dest->c);
box->releaseMsg(msg);
usleep(500000);
}
delete mgr;
}