Serial communication using DEV CPP IDE 4.9.9.2

Reply

Join Date: Dec 2007
Posts: 27
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #1
Dec 22nd, 2007
Hello,I am doing a project in which i need to send and receive data from a microcontroller.I was trying to do this in DEV CPP IDE 4.9.9.2 but couldn't succeed till now.The following is the code i tried compiling.

The code:
  1. #include <bios.h>
  2. #include <conio.h>
  3.  
  4. #define COM1 0
  5. #define DATA_READY 0x100
  6. #define TRUE 1
  7. #define FALSE 0
  8.  
  9. #define SETTINGS ( _COM_9600 | _COM_CHR8 | _COM_NOPARITY | _COM_STOP1)
  10.  
  11. int main(void)
  12. {
  13. int in, out, status, DONE = FALSE;
  14.  
  15. bioscom(0, SETTINGS, COM1);
  16. cprintf("... BIOSCOM [ESC] to exit ...\n");
  17. while (!DONE)
  18. {
  19. status = bioscom(3, 0, COM1);
  20. if (status & DATA_READY)
  21. if ((out = bioscom(2, 0, COM1) & 0x7F) != 0)
  22. putch(out);
  23. if (kbhit())
  24. {
  25. if ((in = getch()) == '\x1B')
  26. DONE = TRUE;
  27. bioscom(1, in, COM1);
  28. }
  29. }
  30. return 0;
  31. }
Previously i got an error saying that bios.h couldn't be found .Then I added bios.h from a TC's include directory.Now it got compiled but when I tried running it ,I got the following errors.

C:/Dev-Cpp/include/bios.h:21: error: variable or field `far' declared void

C:/Dev-Cpp/include/bios.h:21: warning: no semicolon at end of struct or union
C:/Dev-Cpp/include/bios.h:21: error: syntax error before '*' token

Can any one tell me how to solve this.Also can any one give me some sample code or resource to read on serial communication in C using DEV CPP IDE 4.9.9.2
Last edited by Ancient Dragon; Dec 22nd, 2007 at 8:28 am. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,142
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1434
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #2
Dec 22nd, 2007
How to send/receive on serial port is operating system dependent. The code you posted was written for MS-DOS and Dev-C++ only compiles for MS-Windows. You can not use any of the code you posted with that compiler. So you might as well just toss it away and use win32 api functions. Start by reading MSDN for CreateFile function to open the serial port, then scroll down the page until you see Communications Resources.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 27
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #3
Dec 22nd, 2007
Originally Posted by Ancient Dragon View Post
How to send/receive on serial port is operating system dependent. The code you posted was written for MS-DOS and Dev-C++ only compiles for MS-Windows. You can not use any of the code you posted with that compiler. So you might as well just toss it away and use win32 api functions. Start by reading MSDN for CreateFile function to open the serial port, then scroll down the page until you see Communications Resources.
I am doing it in windows Xp and I am unable to run that code.Plese tell me a simple program in DEV CPP Ide where I can send and recieve the data through the serial port.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 241
Reputation: ssharish2005 is on a distinguished road 
Solved Threads: 20
ssharish2005's Avatar
ssharish2005 ssharish2005 is offline Offline
Posting Whiz in Training

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #4
Dec 22nd, 2007
Have a look at this tutorial Serial Programming and this as well.

ssharish
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 326
Reputation: Colin Mac is on a distinguished road 
Solved Threads: 22
Colin Mac Colin Mac is offline Offline
Posting Whiz

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #5
Dec 22nd, 2007
XP comes with the program Hyperterminal which does this.
Last edited by Colin Mac; Dec 22nd, 2007 at 12:20 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,142
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1434
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #6
Dec 22nd, 2007
Originally Posted by infibit View Post
I am doing it in windows Xp and I am unable to run that code.
Yes, I told you so

Originally Posted by infibit View Post
Plese tell me a simple program in DEV CPP Ide where I can send and recieve the data through the serial port.
Simple? There is no such thing. Read through the information in the links I provided in my previous post. You will have to do quite a but of studying.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Solved Threads: 26
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #7
Dec 23rd, 2007
If you want to confine your program for DOS only (warning: highly unrecommended!) and shun learning (warning: again highly unrecommended!) what AD said, you may try to compile this code with some MS-DOs compiler.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 27
Reputation: danibootstrap is an unknown quantity at this point 
Solved Threads: 0
danibootstrap danibootstrap is offline Offline
Light Poster

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #8
Dec 23rd, 2007
I want to know why the above code i mentioned is getting compiled in TC but not DEV CPP IDE and how to make it run in DEV CPP IDE 4.9.9.2
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Solved Threads: 26
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #9
Dec 23rd, 2007
AD has already answered this.

How to send/receive on serial port is operating system dependent. The code you posted was written for MS-DOS and Dev-C++ only compiles for MS-Windows. You can not use any of the code you posted with that compiler.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 241
Reputation: ssharish2005 is on a distinguished road 
Solved Threads: 20
ssharish2005's Avatar
ssharish2005 ssharish2005 is offline Offline
Posting Whiz in Training

Re: Serial communication using DEV CPP IDE 4.9.9.2

 
0
  #10
Dec 23rd, 2007
First of all, the mistake you have been doing is using Turbo C compiler and getting confused between code written for MS-DOS and Windows OS. STOP using your Turbo C compile and just focus on things which are more standard.

>I want to know why the above code i mentioned is getting compiled in TC but not DEV CPP IDE >and how to make it run in DEV CPP IDE 4.9.9.2
You can already see from the error message thrown by the compile on Dev-C++. You have been using some non standard library which was available under TC. But, Dev-C++ doest support those libraries what so ever.

And now explain us, why do you need this code. What is the main purpose of writing this code? What I understand from your post is that, you trying to use this program send and receive data between your microcontroller and your PC. If that was your main intention, there is already inbuilt terminal emulator "HyperTerminal" which does that for you. Where you can transfer your binary to your MController.

If that wasn't your intention, Can you explain you what are you trying to do?

And on the other hand, have a look at the links which I posted in my previous post, there is an article on how to program a serial port for Windows. Its a good Article which was taken from MSDN. If you follow that you will be able to achieve something on Dev-C++.

And start thinking STANDARDS.

ssharish
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC