RS232 input/output help needed

This is a discussion on RS232 input/output help needed within the Linux Programming forums, part of the Platform Specific Boards category; Hi, I'm new at programming and new at Linux. It happened so, that I'm working on a project where i ...

RS232 input/output help needed

Hi, I'm new at programming and new at Linux. It happened so, that I'm working on a project where i thought I'd just edit already written program and have the wished result. Well what do you know! It isn't as easy as I assumed I've got a code of an internet radio tuner, but I want to make it send output (status1, status2 and status3 text in code) character by character (1 second interval between characters) to my serial RS232 port. And I need the program to react (change preset) to input from RS232 serial port. So when I connect my serial LCD and keypad to computer RS232 i get external user interface for the program. In my mind it sounded way easier than it seems to be to me. The OS is Ubuntu. I've got this code:

Plus something more to write to serial port and read from it. I found something about kbhit command, but it seems to be on some special library that's got something complicated about it. I guess it would be too much to expect somebody to give me the edited version of the code, but any information, links, hints or wisdom sharing will be appreciated.

Your not going to get much help from anyone, by posting lines and lines of code you found somewhere and saying little more than "it's not working for me".
We need to know very specifically what isn't working, how would otherwise expect it to, etc.. How can we help you, if you don't even know what's going on you yourself?

I guess you misunderstood me. The code for the internet radio tuner works perfectly. I just need to edit it so i'd be able to control and see the output via RS232.
The question is very easy. Maybe even too easy for such forum. How should I edit this code?
Help me with syntax (what do the "void", "main" and similar commands mean? How is the function created, where do I put it, how do I call and address it). Internet is full of tutorials, but the ones I tried were worthless, so maybe you could help me find something or just answer the question.
I also need help to find required functions to send output to RS232 (this should be some kind of loop which would output character by character) and control it using RS232 keypad.
I hope I made the question understandable. If not, feel free to complain, I'll try to explain it in some other way.

Ok, it was a good advice. I get less error messages, when making small program, so it gives hope someday everything may work I started on LCD program. I managed to build something that looks like a program code:

output.c: In function ‘main’:
output.c:13: error: ‘fd’ undeclared (first use in this function)
output.c:13: error: (Each undeclared identifier is reported only once
output.c:13: error: for each function it appears in.)
output.c:13: error: too few arguments to function ‘write’
output.c: At top level:
output.c:16: error: conflicting types for ‘write’
/usr/include/unistd.h:363: note: previous declaration of ‘write’ was here
output.c: In function ‘write’:
output.c:18: error: void value not ignored as it ought to be

So how come the 'fd' variable is undeclared? It should have a value sent from open-port function. Am I wrong?

You include write() already (from unistd.h), so you can't declare it again, your function needs a new name. Also, the value you read from write(), isn't int* (which is a pointer to an int), it returns just plain int.