Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on transferring from scanner to Python code #12

Open
MelStoltz opened this issue Apr 25, 2016 · 1 comment
Open

Error on transferring from scanner to Python code #12

MelStoltz opened this issue Apr 25, 2016 · 1 comment

Comments

@MelStoltz
Copy link

I am trying this code out below.

import twain
sm = twain.SourceManager(0)
ss = sm.OpenSource()
ss.RequestAcquire(0,0)
rv = ss.XferImageNatively()
if rv:
(handle, count) = rv
twain.DIBToBMFile(handle, 'image.bmp')

It works fine until the rv = ss.XferImageNatively() part
then I get this error

Traceback (most recent call last):
File "C:\Paradigm1\test.py", line 5, in
rv = ss.XferImageNatively()
File "C:\Paradigm1\twain.py", line 2144, in XferImageNatively
return self.xfer_image_natively()
File "C:\Paradigm1\twain.py", line 1974, in xfer_image_natively
rv, handle = self._get_native_image()
File "C:\Paradigm1\twain.py", line 1901, in _get_native_image
(TWRC_XFERDONE, TWRC_CANCEL))
File "C:\Paradigm1\twain.py", line 1565, in _call
return self._sm._call(self._id, dg, dat, msg, buf, expected_returns)
File "C:\Paradigm1\twain.py", line 2320, in _call
raise exc
excTWCC_SEQERROR

Am I doing something wrong?

@denisenkom
Copy link
Owner

Try using higher-level function instead: http://pytwain.readthedocs.io/en/latest/twain.html#twain.Source.acquire_file

It should take care of this error. The error means you called function during wrong state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants