Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want C code to communicate with RS232 in sending and receiving data between two computers like chat program.

I want too to know how to enable and disable the LOOP BACK for RS232 programmatically in C.

Any one have a code for this?
Posted
Comments
OriginalGriff 11-Dec-11 4:07am    
Reason for my vote of one: too lazy to use google.
amertarekt 11-Dec-11 4:25am    
it is not too lazy
i searched but not found solution for my problem

1 solution

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A simple search using text from your subject line gave loads of answers:

"RS232 From C program"[^]

Please, in future do at least basic research yourself, rather than wasting your time, and our time.
 
Share this answer
 
Comments
amertarekt 11-Dec-11 4:18am    
i searched like this but i have two problems

the simple codes i found is very simple

as i think and did before communicating with rs232 need to check for bits in registers to know if data received or all data is sent and so on

in these codes i never found something like this

the second problem is i can not found a solution for my master problem is that how to disable/enable the loopback of rs232 programability
OriginalGriff 11-Dec-11 4:35am    
What loop back are you talking about? I know of no software programmable RS232 loop back which is enabled by default. There is (IIRC) a loopback for test purposes which can be enabled in the driver chip but that (sensibly) defaults to off.
amertarekt 11-Dec-11 4:44am    
some one told me before that there is a function that can be used to Enable the loop back for rs232 so it can work in LOOPBACK mode without make it physically by wires

i want this function to use it in the program
OriginalGriff 11-Dec-11 4:52am    
Why? It does nothing useful for actual applications (it does nothing particularly useful for testing the hardware, either) and it is only going to be applicable to non-usb serial ports (which aren't even fitted to many pcs these days). Plus, it is unlikely that Vista or higher OSes will allow you to play with that low a level hardware anyway.

If it worked, it would be like wiring pins 2&3 together on a standard RS232 connector - so why not make a connector that does that? That way you can remove it without changing your software when you connect to the actual device.

What are you trying to do, that you think this will help?
amertarekt 11-Dec-11 5:10am    
i will tell you my actual problem

i have a handheld terminal called Bitel IC3100

this terminal have RS232 that connected by EZTCP modem (lan modem) inside it

i want to configure this modem to connect to lan and send data over TCP

to do this i want to send AT COMMANDs to COM1 for RS232 in the terminal using C code and library for this terminal and the EZTCP will read it and answer me with ok , no carrier , busy or error

when i tried this i sent a command and when trying to receive data i received the same command

at first i thought it is echo from the modem

i sent a command to disable echo and i also received the same commands i sent every time

i contact to the manufacturer of the terminal and he sent me a code that i found that it is like my code and it had the same result (receive what i send)

some one told me that the terminal's RS232 may be configured as LOOPBACK by default

i think itis wrong because when i do not put the lan wire on the terminal and try my code , i receive nothing and time out and if i connected it i receive the same command i sent.

but i am trying walking in this way and i am trying to find a way to disable the LOOPBACK in RS232 if it is enabled by default

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900