Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What function will comunicate with serial RS232 using C?

Status
Not open for further replies.

shahrol_hisham

Advanced Member level 4
Joined
Aug 1, 2002
Messages
111
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Location
malaysia
Activity points
869
rs232 and c

what function i need to call for comunicate with serial rs232 if i using c ?
 

Re: rs232 and c

hi,
I have seen that you are continuesly facing the rs232 interfacing problem in C..
:?: If you found it difficult to handel rs232 communication in C then I will suggest you to shift on VB... 8)
Well there are varity of functions available to communicate with rs232 ports in C the list is given below..

inp, inpw, outp, outpw <CONIO.H>
inp reads a byte from a hardware port
inpw reads a word from a hardware port
outp outputs a byte to a hardware port
outpw outputs a word to a hardware port

Declaration:
int inp(unsigned portid);
unsigned inpw(unsigned portid);
int outp(unsigned portid, int value);
unsigned outpw(unsigned portid, unsigned value);

Remarks
Both inp and inpw are macros that read from the input port specified by
portid.

Both outp and outpw are macros that write to the output port specified by
portid.

inp reads a byte
inpw reads a 16-bit word (the low byte of the word from portid,
the high byte from portid + 1)
outp writes the low byte of value
outpw writes the low byte of value to portid, and the high byte
to portid + 1, using a single 16-bit OUT instruction

If you call any of these macros when CONIO.H has been included, they are
treated as macros that expand to inline code.

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

Portability
DOS UNIX ANSI C C++

Return Value
inp and inpw return the value read
outp and outpw return the parameter "value"

Other Functions.............................................
inport, inportb outport, outportb
 

rs232 and c

What is OS? For DOS or Windows or Linux?

You should tell us more detail.

Good luck!
 

Re: rs232 and c

This is for Dos...
If you need window version then you will have to swtich on C++ or VC++.. :D
 

Re: rs232 and c

The classic CreateFile, CloseHandle, ReadFile, WriteFile functions.
Other COM port specific functions could be found on MSDN Online under Windows Development>Base Services>Device I/O.

Cheers!
 

Re: rs232 and c

dani said:
This is for Dos...
If you need window version then you will have to swtich on C++ or VC++.. :D

Oh, we were posting at the same time.... I don't ask you. I ask the thread's creator.

His question is not clearly.
 

Re: rs232 and c

How about linux base can some body tell me how....
 

Re: rs232 and c

i try find in internet i got the ..
outb()
ioperm()
but i dont know how to used it. that somebody have a sample. I need your help..
 

Re: rs232 and c

I realy need help because. My date line is near. pls help.
 

rs232 and c

Take a look at 'beyondlogic.org'. Serial interface is described in great detail with sample c code.
 

Re: rs232 and c

I have look on it "beyondlogic.org".I think the note just for dos system only. I have try to include dos.h and conio.h under linux system. what i get is error. There is no such header in linux system.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top