I trying to debug a program which accesses a serial port - /dev/cuaU0 which does exist and I can access it using
This is from
According to
Can anyone explain what is going on?
cu -l /dev/cuaU0 -s 115200
but when I run the program through a debugger I get the following error:-/root/projects/kwuartboot/kwuartboot: unable to open '/dev/cuaU0': m
This is from
Code:
int
main(int argc, char *argv[])
{
struct termios tio;
char *dev;
char *fname;
int tty_fd, file_fd;
int res;
argv0 = argv[0];
if (argc != 3)
usage();
dev = argv[1];
fname = argv[2];
memset(&tio, 0, sizeof(tio));
tio.c_iflag = 0;
tio.c_oflag = 0;
tio.c_cflag = CS8|CREAD|CLOCAL;
tio.c_lflag = 0;
tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 5;
tty_fd = open(dev, O_RDWR | O_NONBLOCK);
if (tty_fd < 0) {
fprintf(stderr, "%s: unable to open '%s': %m\n", argv0, dev);
exit(1);
}
According to
gdb
:-(gdb) p tty_fd
$2 = 3
Can anyone explain what is going on?