diff options
author | nobody <nobody@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2005-08-12 21:04:45 +0000 |
---|---|---|
committer | nobody <nobody@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2005-08-12 21:04:45 +0000 |
commit | 36ab591ec76b0afe06072fb75ad84f2f43f0600a (patch) | |
tree | 09e4e63b0c287c61ed20e82169125e2829166ed9 /pyparallel/src/win32/_pyparallel.c | |
parent | 3e57b3d3ab38509270fb61808494cd485dd10fee (diff) | |
download | pyserial-git-release2_2.tar.gz |
This commit was manufactured by cvs2svn to create tag 'release2_2'.release2_2
Diffstat (limited to 'pyparallel/src/win32/_pyparallel.c')
-rw-r--r-- | pyparallel/src/win32/_pyparallel.c | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/pyparallel/src/win32/_pyparallel.c b/pyparallel/src/win32/_pyparallel.c deleted file mode 100644 index 6316de0..0000000 --- a/pyparallel/src/win32/_pyparallel.c +++ /dev/null @@ -1,69 +0,0 @@ -// Parallel port extension for Win32 -// "inp" and "outp" are used to access the parallelport hardware -// needs giveio.sys driver on NT/2k/XP -// -// (C) 2002 Chris Liechti <cliechti@gmx.net> -// this is distributed under a free software license, see license.txt - -#include <Python.h> -#include <windows.h> -#include <conio.h> - -#define DRIVERNAME "\\\\.\\giveio" - -/* module-functions */ - -static PyObject* -py_outp(PyObject *self, PyObject *args) -{ - int port, value; - if(!PyArg_ParseTuple(args, "ii", &port, &value)) - return 0; - _outp(port, value); - Py_INCREF(Py_None); - return Py_None; -} - -static PyObject* -py_inp(PyObject *self, PyObject *args) -{ - int port, value; - if(!PyArg_ParseTuple(args, "i", &port)) - return 0; - value = _inp(port); - return Py_BuildValue("i", value); -} - - - -static PyMethodDef pypar_methods[] = { - {"outp", py_outp, METH_VARARGS}, - {"inp", py_inp, METH_VARARGS}, - {0, 0} -}; - -/* module entry-point (module-initialization) function */ -void init_pyparallel(void) { - OSVERSIONINFO vi; - - /* Create the module and add the functions */ - Py_InitModule("_pyparallel", pypar_methods); - - //detect OS, on NT,2k,XP the driver needs to be loaded - vi.dwOSVersionInfoSize = sizeof(vi); - GetVersionEx(&vi); - if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) { - HANDLE h; - //try to open driver - h = CreateFile(DRIVERNAME, GENERIC_READ, 0, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (h == INVALID_HANDLE_VALUE) { - //if it fails again, then we have a problem... -> exception - PyErr_Format(PyExc_ImportError, "Couldn't access giveio device"); - } - //close again immediately. - //the process is now tagged to have the rights it needs, - //the giveio driver remembers that - if (h != NULL) CloseHandle(h); //close the driver's file - } -} |