Scanora 0.12.1: What Lies Behind U5 – and Why a Timeout Is Not the End of It
Scanora 0.12.1 is on the Mac App Store. Photos with a dark edge stay whole, pages can be saved as JPEG, a scanner in U5 comes back without switching it off and on – and a diagnosis records what happens on the cable.
In short: Scanora 0.12.1 is on the Mac App Store. Two reports from customers lie behind it. The first is about photos: a borderless print with a nearly black background still came out cropped despite the fixes in 0.11.0. It now stays whole, and every page can also be saved as a JPEG. The second is about a scanner that showed U5 when plugged in and after that no longer existed as far as Scanora was concerned. We measured at the device what sets off U5, and Scanora now brings the scanner back out of it by itself. And because not every fault can be reproduced here, Scanora can now record what happens on the cable. Coming from 0.11.0, this update brings everything from 0.12.0 as well.
Photos: when most of the rows are wrong
Scanora is our macOS app for the KODAK E1030, a sheetfed scanner for which the manufacturer offers no macOS driver. The app speaks the device’s USB protocol directly and turns the sensor image into finished pages.
After the update to 0.11.0, the customer whose photos the last post was about got back in touch. The exposure was right now. But a borderless 10 × 15 print with a night-black background down both sides came out 110 mm wide instead of 149, turned by 9.7° it did not have. Without cropping, black margins remained.
Scanora looks for the edge of the sheet in every row of the sensor image and fits a straight line through those points, guarded against outliers by the median. That assumes most rows find their edge. On this print, only something bright at the bottom of the left side showed the true edge, in 345 of 937 rows. Every other row found its “edge” on the subject in the middle of the picture, and the median followed the majority.
But a row whose paper starts dark always finds its edge inside the picture, never outside it. So a side is now the outermost line that enough rows agree on – rows over at least 10 mm of the sheet’s length, or a twentieth of all rows, to within a millimetre. The slope is searched for both sides at once, since they are parallel. Where nearly every row is on the edge, as with a document or a print with a white border, Scanora computes as before. The Polaroid from the last device check measures to the bit what it did.
That leaves a side where no row shows an edge at all. Even there, the paper is brighter than the backing on average: on this print the darkest areas read 3.5 to 7 per column, the backing 0.5 to 2.1. Beyond every edge found, Scanora now compares lines parallel to it against the backing of the same page, measured in the outer 2 mm of the sensor, and moves the edge out to where the backing begins. The top and bottom work the same way, for a dark sky, say. The search only starts when the millimetre beyond the edge averages 1.5 above the backing, so a document’s edge and a line on the glass beside it stay where they were.
The customer’s scan now measures 149.3 × 101.7 mm at 0.55°. One small thing showed up along the way. When a sheet is fed crooked, its corners lie outside the captured rows, and since 0.11.0 Scanora has filled them in white. Along a document’s margin that looks like margin. Along a dark photo’s border it was a bright strip, up to 1.5 mm wide at 0.55°. For photos, Scanora now repeats the nearest captured pixel there, and over that depth nothing of it shows.
JPEG
The same customer asked for it: if you scan prints to keep and pass on, a PDF around every picture only gets in the way. Every profile now has a file format, PDF or JPEG. With JPEG, every page becomes a file of its own as soon as it is finished: if the stack jams, the first sheets are already in the folder. With {Number} in the file name, each page counts on (Photo 0007, Photo 0008 …). The quality slider now goes up to 100. Text recognition is greyed out for JPEG, because the file has no text layer to put the text in.
U5: a scanner that was no longer there
The second report: barely plugged in, a scanner alternated U and 5 on its display, the power key blinked, and Scanora said “No scanner found” while System Information listed it. Then came “The switch-off time could not be sent to the scanner”, as if that were the problem.
Two things about it were ours. First, Scanora said “No scanner found” for every failure to open, even when the scanner was there and simply did not answer, or another program was holding it. That message sends you to the cable, and the cable was not the problem. Scanora now tells three cases apart and says what to do in each: not connected; in use by another program, with the advice to quit it; connected but not responding. The switch-off time and the profile count only go to a scanner that has answered, and a scanner that does not answer no longer raises a second message.
Second, Scanora never got out of U5. U5 is the scanner’s error display for its USB connection. It then locks both directions of transfer and takes nothing more. The lock sits in the device, not in the Mac, so every new attempt to connect found it again. In practice only switching off and on helped.
What sets off U5
It could not be reproduced at the customer’s, so we measured at our own device how to get into it. One way was known from the analysis of the firmware: when a command ends with certain errors inside the scanner, it switches to U5. The second is more surprising. After every command, the scanner waits for the Mac to collect the answer. If nobody does, it gives up and locks both directions – measured after 5.1 seconds, with U5 on the display.
The way out is a reset of the USB connection, the same bus reset that plugging in triggers. It lifts both locks, the error state and the display, measured in 1.4 seconds. On connecting, Scanora now first asks whether the scanner is locked and, if so, resets it itself, at most once a minute.
That plugging in already resets also means: a scanner that shows U5 right after it meets something in its first seconds that it does not tolerate. One suspicion fell on Scanora itself. Until now the app ended a scan job as a precaution every time it opened the scanner, even when none was open. Those were the first commands a freshly plugged-in scanner saw, and what a device with no open job answers to them is not known for every firmware. Scanora now asks first and only ends a job that really is open, left by a program that quit mid-scan, for instance. Whether that set off U5 at the customer’s, we do not know.
A second suspicion could be cleared. Our device had only ever run on SuperSpeed ports. Behind a USB 2.0 hub it showed the same response times, scanned 300 dpi greyscale and 600 dpi colour duplex without a single timeout, and went into U5 and back out of it the same way.
Why a timeout is not the end of it
Until now every transfer waited as long as the manufacturer’s driver does: 30 seconds out, 60 back, even for status queries a healthy device answers in milliseconds. With a scanner that takes commands and never answers, it took minutes for Scanora to notice. Those queries now get five seconds. Measured, they take 5 ms at most, a single one 136 ms. What really takes time – drawing in a sheet, sending image data over a slow connection – keeps the long limits.
Short time limits have a trap, though, and it is connected to U5. When the Mac gives up waiting, the answer has not gone away; the scanner keeps it ready. If nobody collects it, the scanner locks after five seconds – U5. If the next command collects it, that command gets its predecessor’s answer, and from then on every answer is one command behind. So after a timeout Scanora sends nothing more over the same connection, and the next connection first reads off whatever is still in the line. We measured that at the device too: a bus reset does not throw such an answer away; only reading it does.
Recording what happens on the cable
What sets off U5 at the customer’s on plugging in, we still do not know. Our device does not do it, and guessing gets no further. So Scanora can now record: Settings has Record diagnostics, and Save Diagnostics … in the Help menu turns it into a text file. It contains:
- every command to the scanner with its answer and duration and, after a lock, which direction is locked;
- what the Mac sees on the bus, even when the scanner does not answer at all: speed, port, how many hubs lie in between, the USB controller;
- the scanner’s firmware and the versions of Scanora, macOS and the Mac;
- whether another scanning program is running;
- for each scan, its settings and the measured size of every page.
It does not contain scans, recognised text, file, folder or profile names, or serial numbers. Image data appears only as a total, so many megabytes in so many seconds. When the same query comes back a hundred times with the same result, it is counted rather than written a hundred times. The record lives in the app’s container, two files of 2 MB at most, and only leaves the Mac if you send the file yourself: Scanora still holds no network entitlement.
A video of just over a minute shows how (in German):
What else is in it
- A cancel right after a scan has started is no longer passed over.
- A scan job left open in the scanner by a program that quit is ended cleanly before the next scan.
- A scanner that does not answer no longer holds up the window. A cancel meanwhile waits five seconds at most, ten at the very worst.
The full release notes are on the product page.
What follows for device projects
- A timeout ends only the waiting, not the operation. The device carries on, and its answer is somewhere afterwards. Carry on as if nothing happened after a timeout, and you read the wrong answer to the next command or let the device run into a lock. What happens after a timeout is part of the protocol and has to be measured at the device.
- An error message is an instruction. “No scanner found” sends the user to the cable. Three causes need three messages, and for that the driver has to keep them apart all the way up to the interface.
- Robust statistics are only robust against a minority. The median tolerates outliers as long as they are few. On the dark photo the majority was wrong, but always in the same direction. That knowledge about the measurement carries further than any statistic.
- Build the tool for the fault you cannot reproduce before you need it. A record the customer can switch on and send themselves, with no documents or names in it, is the only look at the cable of a device in the field.
How to repeat measurements like these against the real device regularly is covered in our article on hardware-in-the-loop testing.
Scanora is an independent product of bitshift dynamics GmbH and is not affiliated with the owner of the KODAK trademark. The model name says only which device the app works with.
Frequently asked questions
- How do I get Scanora 0.12.1?
- Through the Mac App Store. If automatic updates are switched on there, the update arrives by itself; otherwise you will find it under Updates in the App Store. Coming from 0.11.0, you get everything from 0.12.0 with it as well. The requirements are unchanged: macOS 13 or later and a Mac with Apple silicon.
- My scanner alternates U and 5 on its display. What do I do?
- With 0.12.1, nothing: Scanora notices on connecting that the scanner is locked and resets the USB connection itself. That takes about one and a half seconds, after which U5 leaves the display. If U5 keeps coming back, please record a diagnosis and send it to us.
- How do I send you a diagnosis?
- Switch on Record diagnostics in Settings, reproduce the problem once, then choose Save Diagnostics … in the Help menu and send the text file to info@bitshift-dynamics.com. The file contains no scans, no recognised text, no file, folder or profile names and no serial numbers.
- When do I choose JPEG rather than PDF?
- JPEG for photos you want to keep, edit or pass on: every page becomes an image file of its own. PDF for documents: all pages of a pass in one file, with searchable text if you like. Text recognition is only available for PDF, because a JPEG has no text layer.
Managing Director, bitshift dynamics
Builds hardware-adjacent software for embedded products with his team – C++, Qt/QML, Embedded Linux and the Yocto Project. bitshift dynamics has worked in this field since 2005.