C # operation parallel port

xiaoxiao2021-03-14  200

parallel port

D0-D7 is the data cable, S0-S7 is a status line, but S0, S1, S2 are invisible (you can also see from the figure), the status line is used to read data, but S0 is different. It is a timeout flag, and other status lines are used to send data from Section 10-11-12-13-15 (which can be seen).

The meaning of the printer pin:

l S0: In EPP (Enhanced Serial Port) mode, this location 1 is in the timeout.

L S1: Useless (estimated is decorative).

L S2: Nothing in most cases.

L S3: Set 0. It is usually called NERROR or NFAULT if the printer occurs.

L S4: If the data is reached, it is set 1. We are usually called SELECT.

L S5: If there is no paper, it is set 1. It is usually called Paperend or PapeRempty or PERROR.

L S6: If the printer gets a byte of data, this location is 0, usually called NACK or NACKNOWLEDGE.

L S7: If the printer is busy, this location is 0, usually called busy.

Control line:

These lines are usually used to output, but sometimes they can be used. They occupy C0-C7 (as shown), but C4, C5, C6, C7 on the interface are not visible, and the port address they take up is 0x37a.

l C0: This pin is reserved. He sends command to read the data on the port (D0-D7). When the computer is started, this bit is set 1, usually called NSTROBE.

l C1: Reserved. You can get the next print line by sending a command to the printer. (LF)

l C2: Reset the printer and empty the data buffer. (Ninitialize)

l C3: Reserved. Set high level open data input. Start the computer to set 0. (NSELECTIN)

Ground:

The needle from G0-G7 is grounded, they are generally used to improve the circuit.

Parallel port connector signal

Parallel input / output address

In my portinterop.cs file, I use this DLL as follows.

Using system;

Using system.Runtime.InteropServices;

Public Class Portaccess, PUBLIC CLASS PORTACCESS

{

[DLLIMPORT ("INPOUT32.DLL", entrypoint = "out32")]

Public Static Extern void Output (int adress, int value);

[DLLIMPORT ("INPOUT32.DLL", entrypoint = "inp32")]

Public Static Extern Int Input (Int AdRess);

}

The Output function is transmitted to the port, and the input is the data from the port.

Such as:

Portaccess.input (888); / / read data from 888 (ie 0x378) port

Portaccess.output (888, 4) // output 4 from 888 port

转载请注明原文地址:https://www.9cbs.com/read-129330.html

New Post(0)