Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

printer port control..

Posted on 1999-01-27
10
Medium Priority
?
222 Views
Last Modified: 2010-05-18
How can I read data from printer port ?

If the setting is ..
LPT1(0x378)..

And How can I write data ?

It's hurry,,...

Thank U !
0
Comment
Question by:can9999
  • 7
  • 3
10 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 200 total points
ID: 1258463
Let's say you want to write a byte to the port..here is how to do it...

typedef unsigned char byte;

void WriteToPort(byte MyByte)
{
  asm {
    mov dl, 378h
    mov al, [MyByte]
    out dl, al
  }
}

to get data you can do something like this...

byte GetPort()
{
  byte tmp;
  asm {
    mov dl, 378h
    in al, dl
    mov [tmp], al
  }
  return tmp;
}

Hope this helps...

-Viktor
--Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1258464
also you can use

outp() and outport()

e.g.

outp(0x378, MyData);

outport(0x378, MyData);

There are other functions that I can look up for you if you need them and are similar to these two i just gave you...

The code I sent above was in assembler so you can use it if oyu want, but I think these two functions are easier to use...

-Viktor
--Ivanov
0
 
LVL 1

Author Comment

by:can9999
ID: 1258465
In your code...

you only read from printer port 0x378.

Is there a anything to initial for reading port ?

What is SPP and .. ?

outp(0x37a, 0x20);
^ some people says above line for reading..

Had you trid it ?

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:viktornet
ID: 1258466
oh for reading use

MyData = inp(0x378);

and for writing use

outp(0x378, MyData);

Hope this helps...

-Viktor
--Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1258467
Why did you give me a C? What's wrong with what I said?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1258468
I gave you all the needed info... What more do you want?

-Viktor
--Ivanov
0
 
LVL 1

Author Comment

by:can9999
ID: 1258469
nothing..

that's enough !

thank U everybody..


0
 
LVL 10

Expert Comment

by:viktornet
ID: 1258470
What do you mean? I was asking you why you gave me so low grade when I gave you all the needed info?!?!
0
 
LVL 1

Author Comment

by:can9999
ID: 1258471
OK !
I'll explain everything..... ^-^

There are several modes for parallel port operating (EPP, BI-DIR, SPP.... etc)
- I don't know what those mean, besides SPP and BI-DIR.

It' is impossible to read data from DATA BUS(d0~d7) of printer port...with using the method what you said alone....

Some steps remain.

1. Set Printer Mode BI-DIR or SPP....
2. Outp(0x37a, 0x20)    <- this command means " I'll read DATA from now "
3. and then READ !
   tmpData = Inp(0x378)

4. If you want to write data,
   Outp(0x37a, 0x00)   <- " I'll write DATA from now "

That's all....


Bye !




 


0
 
LVL 10

Expert Comment

by:viktornet
ID: 1258472
i just think it wasn't appropriate...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question