Scusate se continuo a rompere, ho modificato il codice nel seguente modo:

codice:
#include <stdio.h>   
#include <iostream> 
#include <string.h>   
#include <unistd.h>   
#include <fcntl.h>   
#include <errno.h>    
#include <termios.h>  
using namespace std; 
int main ()
{ 	

int fd;  
		
fd = open("/dev/tty.usbserial-00001004", O_RDWR | O_NOCTTY | O_NDELAY); 	
struct termios options; 
	     
tcgetattr(fd, &options); 
	 	     
cfsetispeed(&options, B9600);    
cfsetospeed(&options, B9600);
 	 	     
options.c_cflag |= (CLOCAL | CREAD);
 	     
tcsetattr(fd, TCSANOW, &options); 	

if (fd == -1) 	
{perror("open_port: Unable to open /dev/tty.usbserial-00001004 - "); 	} 	

else{ 		
char data[]="comando da inserire"; 		
write(fd, data, strlen(data)); 		
perror( "--"); } 	
	
close(fd); 	
return (fd); }
Il codice funziona correttamente e il controller esterno reagisce bene. Il problema è perror che mi restituisce il seguente errore nella funzione write()

codice:
--: Undefined error: 0
è ancora qualcosa legato al baud rate?