C # parallel port

I am trying to send data to LPT1 port using a C # program, unfortunately, without success. I use windows 7 x64. I tried dll x86 and x64 (inpoutx64.dll).

With x64 dll when sending:

Output(888, 255); 

It just continues the program, as everything went fine, but I can’t see anything on my multimeter (only static 0.02 V).

I also tried the following with C ++:

 int main () { int val = 0; printf("Enter a value\n"); scanf("%d", &val); _outp(0x378, val); getchar(); _outp(0x378, 0); return 0; } 

But it throws an exception:

 Unhandled exception at 0x01281428 in ppac.exe: 0xC0000096: Privileged instruction. 

I remember, as soon as I did something like this work on xp (C #, and not on C ++ code), I hope that this is possible on win7 as well. Please help me with this.

Thanks.

+4
source share
1 answer

The IO port in the sense that _outp uses _outp not match what you are trying to do with the parallel port. An I / O port is a level at the processor level that allows you to get raw access to various devices. Using input / output ports with _outp should be what device drivers do. Therefore, it has the privilege (that is, only the kernel) of any version of Windows that is modern enough to have a good separation between the kernel and users (namely, everything that is based on Windows NT). I'm almost 100% sure that you never had _outp to work with XP.

To access the parallel port in higher-level code, simply open it as a regular file using the LPT1: filename.

+6
source

Source: https://habr.com/ru/post/1311364/


All Articles