summaryrefslogtreecommitdiff
path: root/pyparallel/src/win32
diff options
context:
space:
mode:
Diffstat (limited to 'pyparallel/src/win32')
-rw-r--r--pyparallel/src/win32/README.txt9
-rw-r--r--pyparallel/src/win32/makefile9
-rw-r--r--pyparallel/src/win32/simpleio.c47
-rw-r--r--pyparallel/src/win32/simpleio.dllbin0 -> 5632 bytes
4 files changed, 65 insertions, 0 deletions
diff --git a/pyparallel/src/win32/README.txt b/pyparallel/src/win32/README.txt
index b2cb0af..4b6984b 100644
--- a/pyparallel/src/win32/README.txt
+++ b/pyparallel/src/win32/README.txt
@@ -1,3 +1,12 @@
+New:
+simpleio.c provides inp(), outp(), init() these functions are accessed trough
+ctypes.
+
+Build (cygwin/mingw): run "make" the makfile should care of everything.
+
+- - - - - - - - - - - - -
+Old python extension:
+
This extension is needed on Windows as there is no API to
manipulate the parallel port. This Python extension exposes
"inp()" and "outp()" that can be used to manipulate the printer
diff --git a/pyparallel/src/win32/makefile b/pyparallel/src/win32/makefile
new file mode 100644
index 0000000..fad59ee
--- /dev/null
+++ b/pyparallel/src/win32/makefile
@@ -0,0 +1,9 @@
+CFLAGS = -mno-cygwin -mdll -O -Wall
+
+.PHONY: clean FORCE
+
+simpleio.dll: simpleio.o
+ gcc -mno-cygwin -mdll -static -s $^ -Wl,--export-all-symbols,--kill-at -o $@
+
+clean:
+ rm -f simpleio.dll simpleio.o
diff --git a/pyparallel/src/win32/simpleio.c b/pyparallel/src/win32/simpleio.c
new file mode 100644
index 0000000..793cfac
--- /dev/null
+++ b/pyparallel/src/win32/simpleio.c
@@ -0,0 +1,47 @@
+// Parallel port extension for Win32
+// "inp" and "outp" are used to access the parallelport hardware
+// needs giveio.sys driver on NT/2k/XP
+//
+// (C) 2005 Chris Liechti <cliechti@gmx.net>
+// this is distributed under a free software license, see license.txt
+
+#include <windows.h>
+#include <conio.h>
+
+#define DRIVERNAME "\\\\.\\giveio"
+
+/* module-functions */
+
+WINAPI void outp(int port, int value) {
+ _outp(port, value);
+}
+
+WINAPI int inp(int port) {
+ int value;
+ value = _inp(port);
+ return value;
+}
+
+WINAPI int init(void) {
+ OSVERSIONINFO vi;
+
+ //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
+ //"Couldn't access giveio device";
+ return 1;
+ }
+ //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
+ }
+ return 0;
+}
diff --git a/pyparallel/src/win32/simpleio.dll b/pyparallel/src/win32/simpleio.dll
new file mode 100644
index 0000000..df480ac
--- /dev/null
+++ b/pyparallel/src/win32/simpleio.dll
Binary files differ