Rex,

Would you mind showing me your source for your GPS code reader since it seems to be working? Alternatively could you give my code below a quick scan and see if there is anything glaringly obvious? I basically ripped most of this code from my original x86 based MP3 player which read an IR remote ontroller so I am fairly confident it's OK.

Basically my code is either receiving nothing (I know data is definitely going in to the port) or receiving zeroes. I have tried t at a standard baud rate to rule out baud rate problems with my custom kernel.

Also I see how the -s- switch is working now and it would appear that I need it. However it made no difference.

I also needed to turn of terminal echo and that seems to be working fine for the moment. My code is working in the sending direction but not in the recieving. It appears that something else is swallowing my received data.

I do plan on a kernel hack (basically using a lot of Hijack for screen functions) eventually but I am trying to run the code in userspace initially for testing.

Thanks,

My code:


int main(int argc, char *argv[])
{
unsigned char c, queue[32];
struct termios options;
struct timeval timeout;
fd_set fds;

printf("Opening serial port...\n");
if ((changer_handle = open("/dev/ttyS1", O_RDWR | O_NOCTTY | O_NDELAY)) < 0) {
fprintf(stderr, "Couldn't get serial port.\n");
exit(1);
}
printf("Serial port open.\n");


printf("Getting Serial options\n");
/* Get the current options for the port... */
tcgetattr(changer_handle, &options);

/* Set the baud rates to 2400... (actually 1500) */
cfsetispeed(&options, B2400);
cfsetospeed(&options, B2400);

/* Enable the receiver and set local mode... */
options.c_cflag |= (CLOCAL | CREAD);

options.c_cflag &= ~CSIZE; /* Mask the character size bits */
options.c_cflag |= CS8; /* Select 8 data bits */

/* No parity (8N1): */
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;

/* No flow control */
options.c_cflag &= ~CRTSCTS;

/* Set the new options for the port... */
tcsetattr(changer_handle, TCSAFLUSH, &options);
printf("Setting Serial options\n");

/* Send a hello command - expect 9 8 2 back */
queue[0] = 0x1;
queue[1] = 0x8;
queue[2] = 0xA;
send_mbus(queue, 3);

usleep(1000000);

/* Make the set */
FD_ZERO(&fds);
FD_SET(changer_handle, &fds);

/* Make the timeout */
timeout.tv_sec=3;
timeout.tv_usec=0;

while(1) {
/* Do a select on the changer input */
if (select(changer_handle + 1, &fds, NULL, NULL, &timeout) > 0) {

if (read(changer_handle, &c, 1)) {
printf("%02x", c);
}
} else {
break;
}
}

cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
tcsetattr(changer_handle, TCSAFLUSH, &options);

close(changer_handle);
}
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)