# serial port api

**URL:** <https://forums.digi.com/t/serial-port-api/5946>\
**Category:** NET+OS\
**Created:** [March 3, 2004, 11:49am UTC](https://forums.digi.com/t/serial-port-api/5946 "2004-03-03T11:49:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/digi/original/1X/11da31a6a1fbcd03ef21d3f785c317c824009ae2.png) [@system](https://forums.digi.com/u/system)\
**Post date:** [March 3, 2004, 11:49am UTC](https://forums.digi.com/t/serial-port-api/5946/1 "2004-03-03T11:49:23Z")

</div>

Hello, I am using the serial port on a connectme board development board with NET+OS 6.0. Until now, the following code worked fine. The open, read, write calls all work and data is transmitted successfully: … zeroFd = open (“/com/0”,(O\_RDWR) ); if (zeroFd \<0){ printf (“Can’t open com0 [%d].  
“, getErrno()); return; } … result = write (zeroFd, msgBuf, result+1); … (in another thread) result = read(zeroFd, msgBuf, 4); This is fine for a standard configuration (9600 bauds, no parity, etc.). But now I need to use a specific configuration (115200 bauds, no parity, etc.). To do this, I tried to use the termcap api, the ioctl api and always got error messages returned from all configuration functions. This is the code I would like to get to work: (in bsp.h) #define BSP\_SERIAL\_PORT\_API BSP\_SERIAL\_API\_TERMIOS (in my\_ser\_test.c, i.e. my application code) void configSerial() { int zeroFd, result, status, baudrate; struct termios tios; … zeroFd = open (”/com/1”,(O\_RDWR) ); if (zeroFd \<0){ printf ("Can’t open com1 [%d].  
", getErrno()); return; } tcgetstats( zeroFd, &ser\_status ); do{ if ( (ser\_status.mstat & (MS\_DCD | MS\_DSR)) == 0 ) { printf ("Connect Serial cable!  
"); tx\_thread\_sleep(100); } }while( (ser\_status.mstat & (MS\_DCD | MS\_DSR)) == 0 ); /\* set the baud rate \*/ baudrate = SIO\_115200\_BAUD; tcgetattr(zeroFd, &tios); cfsetospeed(&tios, baudrate); if ( cfgetospeed(&tios) != baudrate ) { printf ("ioctl(Baud set)  
", getErrno()); return; } … } For now, all the calls: tcgetstats never provides the proper result and we go in a endless while loop. And the call to cfgetospeed always fails. Once this works, I shall be able to succeed doing read/write accesses at 115200 bauds. Can you help ? Thanks, Brice
