# Setup of serial channel

**URL:** https://forums.digi.com/t/setup-of-serial-channel/5966
**Category:** NET+OS
**Created:** [November 29, 2006, 1:22pm UTC](https://forums.digi.com/t/setup-of-serial-channel/5966 "2006-11-29T13:22:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mhz](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@mhz](https://forums.digi.com/u/mhz)
#### Post date: [November 29, 2006, 1:22pm UTC](https://forums.digi.com/t/setup-of-serial-channel/5966/1 "2006-11-29T13:22:03Z")

</div>

I am new to use the netos63 software. I have tried to use the termios drivers without success. I have used the template software.  
void applicationStart (void)

{  
struct termios term;  
int fd;  
char message[] = "Print with termios  
";

```
printf ("Print with printf

```

");  
tx\_thread\_sleep(10);

```
fd = open("/com/0", (O_RDWR | O_NONBLOCK));
if (fd &lt; 0)
{
    printf("Error in open() file = %d

```

", getErrno());  
}  
if (tcgetattr(fd, &term) \< 0)  
{  
printf("Error in tcgetattr() = %d  
", getErrno());  
}

```
term.c_iflag = 0;
term.c_oflag = 0;
term.c_cflag &amp;= ~CSIZE;
term.c_cflag |= CS8; // 8 bit
term.c_cflag &amp;= ~CSTOPB; // 1 stop bit
term.c_cflag &amp;= ~PARENB; // No parity
term.c_cflag |= CRTS; // Enable RTS for input flow control
term.c_cflag |= CCTS; // Enable CTS for output flow control
term.c_xflag = 0;
term.c_cc[0] = 0;
term.baud = 9600;

if (tcsetattr(fd, TCSANOW, &amp;term) &lt; 0)
{
    printf("Error in tcsetattr() = %d

```

", getErrno());  
}

```
if (write(fd, message, strlen(message)) &lt; 0)
{
    printf("Error in write() = %d

```

", getErrno());  
}

```
printf ("Print with printf again

```

");  
tx\_thread\_suspend(tx\_thread\_identify());  
}

The printf’s print the text.  
The open() comes with errno 16 (mount device busy) and tcgetattr and tcsetattr will therefore come with error 22 (invalid argument).  
I suppose that this means that the /com/0 has already been opened, but I am not able to close it first because I don’t know the file descriptor.  
The termios API’s are used, because they are defined in the bsp connectme platform as default.  
What is the problem?

---

<div class="post-metadata">

### Author: ![Humanoid](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@Humanoid](https://forums.digi.com/u/Humanoid)
#### Post date: [November 30, 2006, 1:07pm UTC](https://forums.digi.com/t/setup-of-serial-channel/5966/2 "2006-11-30T13:07:12Z")

</div>

Try to set the flags before opening the COM port. And also comment the COM0 -lines from appconf.h so the debugger won’t use them in its own purposes. (COM0 is for debugger serial connection ind default).
