Serial communication missing bytes


I’ve got a Connect ME 9210 development board with Digi ESP for Embedded Linux.
I enable the serial device driver in the kernel in selecting :

Character devices --> Serial drivers --> Digi NS921x serial port support --> Console on Digi NS921x serial

Then, I enable serial port A as UART in selecting :

System Type -->NS9xxx Implementations --> Digi Connect ME 9210 on Devboard --> Serial port A --> port configuration --> RX/TX only 

I cable my device on P7 (connector on Devboard) TxDevice with RxDigi (Pin 8) and RxDevice with TxDigi(Pin 6).
In my program, I precise /dev/ttyNS0.

After flashing the Digi Connect ME 9210, I disable RS232 with the connector P5 and I execute my program via telnet.

My program sent a frame and compare it with the received frame. It miss some bytes at the beginning of the frame.

I don’t think the problem comes from my program.

So, have I the good configuration and cabling? Perhaps I miss something.

Thank you for your help

Independently of my problem of missing bytes, I have a problem with ioctl() function.

This is my function to receive data from UART :

bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen)
  int res;
  int byteCount;
  fd_set rfds;
  struct timeval tv;

  // Reset the output count
  *pszRxLen = 0;

  do {
    // Reset file descriptor
    tv = timeout;
    res = select(((serial_port_unix*)sp)->fd+1, &rfds, NULL, NULL, &tv);

    // Read error
    if (res < 0) {
      DBG("%s", "RX error.");
      return false;

    // Read time-out
    if (res == 0) {
      if (*pszRxLen == 0) {
        // Error, we received no data
        DBG("%s", "RX time-out, buffer empty.");
        return false;
      } else {
        // We received some data, but nothing more is available
        return true;

    // Retrieve the count of the incoming bytes
    res = ioctl(((serial_port_unix*)sp)->fd, FIONREAD, &byteCount);
    if (res < 0) {
    	DBG("ioctl error. res = %+d",res);
    	return false;

    // There is something available, read the data
    res = read(((serial_port_unix*)sp)->fd,pbtRx+(*pszRxLen),byteCount);

    // Stop if the OS has some troubles reading the data
    if (res <= 0){
    	DBG("read error.res = %+d",res);
    	return false;

    *pszRxLen += res;

  } while (byteCount);

  return true;

When I execute it, I obtain :

ioctl error. res = -1
ioctl :: Input/output error

I can see on this thread :,1206_offset,0
that we can use tcgetbuffers() with Net+OS , I’d like to know if it’s the case because of problem with ioctl() if so, how can I do with using Digi Connect ME 9210 with linux ?

Thanks for your help.

Problem solved