Fix SANE custom page size scan failure and improve invalid parameter …#842
Open
kovacsbv wants to merge 1 commit into
Open
Fix SANE custom page size scan failure and improve invalid parameter …#842kovacsbv wants to merge 1 commit into
kovacsbv wants to merge 1 commit into
Conversation
…error message - Fix PageAlign switch in SaneScanDriver.SetOptions where HorizontalAlign.Left and HorizontalAlign.Right cases were swapped, causing non-zero offsetX values for Left-aligned profiles that pushed the scan area to the right edge of the bed. For small custom page sizes (e.g. 3x5 cards) this produced a tl-x value outside the valid range for the configured page-width, causing sane_start to return SaneStatus.Invalid and NAPS2 to report 'scanner is offline'. - Replace the TODO at SaneScanDriver line 318 with DeviceInvalidParameterException. SaneStatus.Invalid at that point originates from sane_start (SaneOptionController .TrySet handles its own exceptions internally and never propagates them), so it indicates rejected scan parameters rather than a connectivity failure. This also prevents ScanController's device re-query logic from firing unnecessarily on parameter errors. - Add DeviceInvalidParameterException to DeviceException.cs with a user-facing message directing users to check page size, alignment, and resolution settings. - Add geometry debug log in SetOptions after SetArea is called, recording tl-x, tl-y, br-x, br-y, width, and height values for diagnostic purposes. Note: SdkResources.Designer.cs was manually updated as ResGen is not available on Linux. The new DeviceInvalidParameter string should be added to translate.naps2.com for localization.
Owner
|
If this fixes your issue then you should just be able to switch "Horizontal Align" to "Right" in your profile (which is the default) to fix the problem. The left v right delineation is arguably weird, but it depends what perspective you're looking at it from (e.g. for a flatbed scanner, are you looking top down, or from the perspective of the paper). In any case it's been this way for 13 years and it can't be changed without breaking/confusing everyone else. |
Author
|
Perhaps the best way would be to have a new setting such as "reverse alignment" that defaults to the old way, but allows everyone else to do what makes sense. I put in 3"x5" left-aligned and get "printer disconnected"? Something still has to change. |
Author
|
Closes #838 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…error message
Fix PageAlign switch in SaneScanDriver.SetOptions where HorizontalAlign.Left and HorizontalAlign.Right cases were swapped, causing non-zero offsetX values for Left-aligned profiles that pushed the scan area to the right edge of the bed. For small custom page sizes (e.g. 3x5 cards) this produced a tl-x value outside the valid range for the configured page-width, causing sane_start to return SaneStatus.Invalid and NAPS2 to report 'scanner is offline'.
Replace the TODO at SaneScanDriver line 318 with DeviceInvalidParameterException. SaneStatus.Invalid at that point originates from sane_start (SaneOptionController .TrySet handles its own exceptions internally and never propagates them), so it indicates rejected scan parameters rather than a connectivity failure. This also prevents ScanController's device re-query logic from firing unnecessarily on parameter errors.
Add DeviceInvalidParameterException to DeviceException.cs with a user-facing message directing users to check page size, alignment, and resolution settings.
Add geometry debug log in SetOptions after SetArea is called, recording tl-x, tl-y, br-x, br-y, width, and height values for diagnostic purposes.
Note: SdkResources.Designer.cs was manually updated as ResGen is not available on Linux. The new DeviceInvalidParameter string should be added to translate.naps2.com for localization.