Programming serial port

Status
Not open for further replies.
OP
bizzare_blue

bizzare_blue

Journeyman
Port

Actually, I want to get a signal from the port where a device may b attatched.....How can I do this?


Also, I wanted 2 know bt Remote Interfacing....
 

ramprasad

In the zone
hi..

This is absolutely possible....
I have done it....
but currently , I dont remember anything, will let u know in a few days....

Regards,
Ramprasad
 
quoting directly from my c++ compiler.....

DOS.h


þ inport reads a word from a hardware port
þ inportb reads a byte from a hardware port
þ outport outputs a word to a hardware port
þ outportb outputs a byte to a hardware port

Declaration:
þ int inport(int portid);
þ unsigned char inportb(int portid);
þ void outport(int portid, int value);
þ void outportb(int portid, unsigned char value);

Remarks:
þ inport works just like the 80x86 instruction IN. It reads the low
byte of a word from portid, the high byte from portid + 2.
þ inportb is a macro that reads a byte
þ outport works just like the 80x86 instruction OUT. It writes the
low byte of value to portid, the high byte to portid + 1.
þ outportb is a macro that writes value

Argument³ What It Is

portid ³ Inport port that inport and inportb read from;
³ outport port that outport and outportb write to
value ³ Word that outport writes to portid;
³ byte that outportb writes to portid.

If you call inportb or outportb when DOS.H has been included, they are
treated as macros that expand to inline code.

If you don't include DOS.H, or if you do include DOS.H and #undef the
macro(s), you get the function(s) of the same name.

Return Value:
þ inport and inportb return the value read
þ outport and outportb do not return


Name Address IRQ
COM 1 3F8 4
COM 2 2F8 3
COM 3 3E8 4
COM 4 2E8 3

does this help you?
 

sujithtom

Ambassador of Buzz
I heard (but i am not sure) that in Windows u can treat ports as files and write and read data from them. Try to open it in binary mode.
 
Status
Not open for further replies.
Top Bottom