File descriptor read problem

Hi,
I have tested “read” from file descriptor and I have noticed serious issue. Please look at code below:

int Gps::OpenNMEA()
{
    int FD = open("/dev/nmea", O_RDONLY);
    le_fdMonitor_Create("Nmea", FD, NmeaHandler, POLLIN);
    return FD;
}

void Gps::NmeaHandler(int FD, short Event)
{
    if (Event & POLLIN)
    {
        char Buff[10];
        std::string Res;
        ssize_t BytesRead = read(FD, Buff, 10);

        if(BytesRead > 10)
        {
        	std::string Err = "ERROR. Read bytes:";
        	Err.append(std::to_string(BytesRead));
        	LE_INFO(Err.c_str());
        }

        Res.append(Buff, BytesRead);

        LE_INFO(Res.c_str());
    }
}

The error should not happened because ‘read’ function should read max 10 bytes. However function ‘read’ reads much more bytes (in this case 548 bytes). Initially my buffer was 1024 big and I did not solve the problem because ‘read’ function was reading 4000-8000 bytes.

Nov 22 22:22:08 | mod[12951]/Component T=main | Gps.cpp NmeaHandler() 104 | ERROR. Read bytes:548
Nov 22 22:22:08 | mod[12951]/Component T=main | Gps.cpp NmeaHandler() 109 | $GPGSV,4,1,13,02�+^E

Does someone know why the function behave like this?

I wonder if this is not conflicting with some NMEA service that is used to pipe /dev/nmea to /dev/ttyGS0 (= USB).

There is something called ‘restartNMEA’ on wp85 that does that.
Try to see if it is running with ps aux | grep /dev/nmea.
If you see something like cat /dev/nmea, then it is running.

If it is, then you need to disable USB NMEA, and to do so try:

# microcom -E /dev/ttyAT
at!entercnd="A710"
OK
at!usbcomp?
Config Index: 1
Config Type:  1 (Generic)
Interface bitmask: 00001009 (diag,modem,mbim) 

OK
at!usbcomp=?
!USBCOMP: 
AT!USBCOMP=<Config Index>,<Config Type>,<Interface bitmask>
  <Config Index>      - configuration index to which the composition applies, should be 1

  <Config Type>       - 1:Generic

  <Interface bitmask> - DIAG     - 0x00000001,
                        NMEA     - 0x00000004,
                        MODEM    - 0x00000008,
                        AT       - 0x00000010,
                        OSA      - 0x00000020,
                        RAWDATA  - 0x00000040,
                        RMNET0   - 0x00000100,
                        RMNET1   - 0x00000400,
                        MBIM     - 0x00001000,
                        RNDIS    - 0x00004000,
                        AUDIO    - 0x00010000,
                        ECM      - 0x00080000,
  e.g.
  10D  - diag, nmea, modem, rmnet interfaces enabled
  1009 - diag, modem, mbim interfaces enabled

OK
at!usbcomp=1,1,1009
OK
at!reset
OK

Hi,
Still the same problem.