Cannot call seek on a sequential device error after moving project from Qt4.8.7 to Qt5.5.
-
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 deviceThe 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.
-
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 deviceThe 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.
@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.
-
@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.
@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.
-
@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.
@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.
-
@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.
HI,
I got it. But how dose it work in Qt 4.8.7? I don't understand.
Thank you for your time.
Regards.