I'm attempting to write a tool that uses IrDA to communicate with Uwatec dive computers...on a Mac. The USB IrDA device I'm using provides a serial device (/dev/cu.IrDA-IrCOMM0 and /dev/tty.IrDA-IrCOMM0) that can be used to send and receive data. Unfortunately, the Mac does not provide an IrDA socket layer.
I've confirmed using the command line tool that shipped with the device driver that it can listen and receive IrDA communications from other devices. However, while the command line tool tells me it is communicating at 9600 baud, the rest of the settings (bits, stop bit, parity, flow control, etc) are not presented back to me.
I've tried writing my own program to listen to the data, but it is unable to receive any data and I believe the reason is because these settings are not correct. So, assuming that I'm just trying to listen to the 9600 baud IrDA discovery packets that are being sent around, what are the other settings I need to use?
If it helps, here's the snippet of code I'm currently using to set the communication parameters -- which doesn't work:
#define DEVICE "/dev/cu.IrDA-IrCOMM0"
int main(void) {
FILE *device;
struct termios ttystate;
device = fopen(DEVICE, "rw");
//get the terminal state
tcgetattr(fileno(device), &ttystate);
//turn off canonical mode and echo
ttystate.c_lflag &= ~(ICANON | ECHO);
//minimum of number input read.
ttystate.c_cc[VMIN] = 1;
cfsetspeed(&ttystate, B9600); // Set 9600 baud····
ttystate.c_cflag |= (CS8 | // Use 8 bit words
PARENB | // parity enable
PARODD | // odd parity
CCTS_OFLOW | // CTS flow control of output
CRTS_IFLOW);// RTS flow control of input
//set the terminal attributes.
tcsetattr(fileno(device), TCSANOW, &ttystate);
return EXIT_SUCCESS;
}