Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cannot call seek on a sequential device error after moving project from Qt4.8.7 to Qt5.5.

Cannot call seek on a sequential device error after moving project from Qt4.8.7 to Qt5.5.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • LeonidL Offline
    LeonidL Offline
    Leonid
    wrote on last edited by
    #1

    Hi.
    I have code in the project on Linux Ubuntu which communicate with PCI device. PCI device is a extended PCI - USB 3.0 board. The car dreader is connected to this board.
    After moving project from Qt4.8.7 to Qt5.5 I receive the message:
    QIODevice::seek (QFile, "/dev/disk/by-path/pci-0000:00:14.0-usb-0:3.4:1.0-scsi-0:0:0:0"): Cannot call seek on a sequential device

    The code of function where this message appear is:
    // Device file
    QFile destFile(deviceNodePath);

    // Zeroes to fill raw header with
    char zeroes[RAW_HEADER_SIZE];
    // Initialize values
    memset(zeroes, 0, RAW_HEADER_SIZE);
    // Open device file
    if(destFile.open(QIODevice::WriteOnly) == false)
        throw QString("Device opening failed when trying to delete raw header");
    // Seek to raw header signature
    if (destFile.seek(signatureOffset) == false)
        throw QString("Seek operation failed when deleting raw header");
    // Write zeroes over raw header
    if (destFile.write(zeroes, RAW_HEADER_SIZE) != RAW_HEADER_SIZE)
        throw QString("Writing operation failed when deleting raw header");
    // Close device file
    destFile.close();
    

    In Qt 4.8.7 function seek() worked and returned “true”. After moving it return “false”.
    According to documentation it shouldn't work and on Qt 4.8.7 either.
    How I can rewrite this code for sequential file? Or may be I something don't understand.

    Thanks in advance.

    kshegunovK 1 Reply Last reply
    0
    • LeonidL Leonid

      Hi.
      I have code in the project on Linux Ubuntu which communicate with PCI device. PCI device is a extended PCI - USB 3.0 board. The car dreader is connected to this board.
      After moving project from Qt4.8.7 to Qt5.5 I receive the message:
      QIODevice::seek (QFile, "/dev/disk/by-path/pci-0000:00:14.0-usb-0:3.4:1.0-scsi-0:0:0:0"): Cannot call seek on a sequential device

      The code of function where this message appear is:
      // Device file
      QFile destFile(deviceNodePath);

      // Zeroes to fill raw header with
      char zeroes[RAW_HEADER_SIZE];
      // Initialize values
      memset(zeroes, 0, RAW_HEADER_SIZE);
      // Open device file
      if(destFile.open(QIODevice::WriteOnly) == false)
          throw QString("Device opening failed when trying to delete raw header");
      // Seek to raw header signature
      if (destFile.seek(signatureOffset) == false)
          throw QString("Seek operation failed when deleting raw header");
      // Write zeroes over raw header
      if (destFile.write(zeroes, RAW_HEADER_SIZE) != RAW_HEADER_SIZE)
          throw QString("Writing operation failed when deleting raw header");
      // Close device file
      destFile.close();
      

      In Qt 4.8.7 function seek() worked and returned “true”. After moving it return “false”.
      According to documentation it shouldn't work and on Qt 4.8.7 either.
      How I can rewrite this code for sequential file? Or may be I something don't understand.

      Thanks in advance.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @Leonid
      Hello,
      Try substituting the seek with a read?

      if (!destFile.open(QIODevice::ReadWrite))
          throw QStringLiteral("Device opening failed when trying to delete raw header");
      if (destFile.read(signatureOffset).size() != signatureOffset)
          throw QStringLiteral("Seek operation failed when deleting raw header");
      

      Kind regards.

      Read and abide by the Qt Code of Conduct

      LeonidL 1 Reply Last reply
      0
      • kshegunovK kshegunov

        @Leonid
        Hello,
        Try substituting the seek with a read?

        if (!destFile.open(QIODevice::ReadWrite))
            throw QStringLiteral("Device opening failed when trying to delete raw header");
        if (destFile.read(signatureOffset).size() != signatureOffset)
            throw QStringLiteral("Seek operation failed when deleting raw header");
        

        Kind regards.

        LeonidL Offline
        LeonidL Offline
        Leonid
        wrote on last edited by Leonid
        #3

        @kshegunov
        Hello,

        I verified you solution. It works but read() takes a lot of time. May be because signatureOffset too big.

        Thank you very much.

        kshegunovK 1 Reply Last reply
        0
        • LeonidL Leonid

          @kshegunov
          Hello,

          I verified you solution. It works but read() takes a lot of time. May be because signatureOffset too big.

          Thank you very much.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Leonid
          Hello,

          read() takes a lot of time. May be because signatureOffset too big.

          Possibly yes, but sadly I don't know another way to "seek" through a sequential stream. As their name suggests, they're not random-access devices, and as such are not optimized for going to an arbitrary location.

          Kind regards.

          Read and abide by the Qt Code of Conduct

          LeonidL 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @Leonid
            Hello,

            read() takes a lot of time. May be because signatureOffset too big.

            Possibly yes, but sadly I don't know another way to "seek" through a sequential stream. As their name suggests, they're not random-access devices, and as such are not optimized for going to an arbitrary location.

            Kind regards.

            LeonidL Offline
            LeonidL Offline
            Leonid
            wrote on last edited by Leonid
            #5

            @kshegunov

            HI,

            I got it. But how dose it work in Qt 4.8.7? I don't understand.

            Thank you for your time.
            Regards.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved