I am trying to talk to a power supply from my mac OS X Yosemite. The code works fine on a linux machine, but when I try it on my mac, it does not work. I am using a usb-serial converter and have downloaded the PL-2303 driver. The driver shows up in my /dev folder as cu.usbserial and tty.usbserial.
The part of my code that fails:
fd = initserial("/dev/cu.usbserial");
int initserial(char port[])
{
struct termios shimtermios;
int fd;
if((fd=open(port,O_RDWR)) < 0) {
perror("Opening the RS-232 port failed for initserial\n");
exit(-1);
}
if (tcgetattr(fd, &shimtermios) < 0) {
perror("couldn't get terminal attributes\n");
exit(-2);
}
shimtermios.c_iflag=012005;
shimtermios.c_oflag=014004;
shimtermios.c_cflag=03206276;
shimtermios.c_lflag=05060;
cfsetospeed(&shimtermios,B19200);
if (tcsetattr(fd, TCSAFLUSH, &shimtermios) < 0) {
perror("couldn't set terminal attributes\n");
exit(-3);
}
return (fd);
}
I get the following error message
couldn't set terminal attributes
: Invalid argument
Please let me know if you have any experience with this linux/unix issue. Thank you so much!