BlitzMax & Lego Mindstorms NXT

BlitzMax Forums/BlitzMax Programming/BlitzMax & Lego Mindstorms NXT

Ok, I just couldn't leave it be and did some more research and read several lines of POSIX C-code. From what I have learned, this -should- work, but it still doesn't:

int openserial(const char *deviceFilePath,int baudrate){
    int         fileDescriptor = -1;
    int         status = 0;
    struct termios  options;
 
    fileDescriptor = open(deviceFilePath, O_RDWR | O_NOCTTY | O_NONBLOCK);
    tcgetattr(fileDescriptor, &options);
 
	options.c_iflag &= ~(INPCK | PARMRK | BRKINT | INLCR | ICRNL | IXANY);			// disable input processing
	options.c_lflag = 0;					// no local flags
 	options.c_oflag &= ~OPOST;				// Output: Raw mode
	options.c_cflag &= ~CSIZE;
    options.c_cflag |= CS8;					// 8 Bits
	options.c_cflag &= ~PARENB;				// No parity
	options.c_cflag &= ~CSTOPB;				// 1 Stop Bit
	options.c_cflag |= CRTSCTS;				// flow ctrl
	options.c_cc[VMIN] = 0;					// read() returns immediately
    options.c_cc[VTIME] = 0;				// with the data in buffer

    tcsetattr(fileDescriptor, TCSANOW, &options);

	// Set speed to 460.8K
    cfsetispeed(&options, 460800);
    cfsetospeed(&options, 460800);
  
	// Set RTS
    ioctl(fileDescriptor, TIOCMGET, &status);
	status |= TIOCM_RTS;
    ioctl(fileDescriptor, TIOCMSET, &status);

	// Set DTR
    ioctl(fileDescriptor, TIOCMGET, &status);
    status |= TIOCM_DTR;
    ioctl(fileDescriptor, TIOCMSET, &status);



    return fileDescriptor;
}