When I try to open a serial port (Arduino attached via USB) from a Cocoa App using plain C code in objective C function:
int fd;
fd = open("/dev/cu.usbmodem1421", O_RDWR | O_NOCTTY | O_NDELAY );
int errornumber = errno;
if( fd == -1 ){
printf("Nope:%i\n", errornumber);
}else{
printf("Yip!");
}i get the error code 1, Operation Not Permitted. But, when I try exactly the same thing from a Command Line Tool project, with Objective-C selected as the language, and run it, it works fine.
Any ideas why it does not work in a Cocoa App would be greatly appreciated. Cocoa Objective-C code is started by being linked up to a button, printf output shows that the code is running when the button is pressed, and that open attempt is made, and the error no is 1.
When run in a command line too, I get the Yip! output.
Thanks in advance,
JR