Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 19th, 2005, 6:46 PM   #1
Light
Newbie
 
Join Date: Feb 2005
Location: USA, Western States
Posts: 4
Rep Power: 0 Light is on a distinguished road
C programing control of the Serial Port.

I would like to be able to montor and control equipment through the serial ports "com 1 or com 2" of 286 up and 386 up or higher processor computers. As many of you may know the 80-286 was a 16 bit computer and the 80-386 was the start of the 32 bit processors. A friend that has some experience with programming languages advised me that it was possible to accomplish this project easier through the C programming language rather than learn to write programs in assembly.

Some 3 decades ago I studied Fortran and Basic so I purchase a tutor book Sams "Teach Yourself C in 21 days". My friend helped me to download/set up the DJGPP "C" compiler and rhide editor software and get started using the tutor and compiler. During this process we learned that because of the 16 and 32 bid difference of processors, the version of the DJGPP C compiler that I had would only produce programs that would work on the 32 bit machine. To verify this I also tried running a simple compiled C program on the 286, which failed. (One thing that bothered me when doing this was the size of the resulting program file for such a simple piece of code ( Just printing out Hello! on the screen). I was thinking at the time that the code generated by the compiler would probably take a hard drive to support running the program.) Can any one explain why there is such a large program for such a small task"

After studying the C language for a week I got far enough along to begin searching for the functions that would allow me to control and output data through the serial ports. This data will consist of a frame of words where each word (consisting of an equipment address and message bits) will address a particular piece of equipment tied to a transmission line which will recognize its own address code, decode the message and either turn the equipment on or off through its own circuitry.

The only function that I have found is "Std Aux" which is mentioned in my tutor book as control of serial port com 1. At this point I was stopped as there is no definition of this function within my tutor book.

I will need a lot of help learning C well enough to write the programs needed to complete this project. For those willing to help, here are four to get me off on the right foot.

Questions:

1. Because I have a lot more 80-286 computers that 386 and above, I would like to be able to write my control programs, so that I can compile them for the 286 also. Does anyone know of a C compiler version that will allow me to write programs for the 286 and with minor modifications to the source code, use it for the 32 bit machines?

2. Can anyone shed light on the C "Std Aux" function as to its complete discription, and how it is use? Since My tutor does not discuss it or state examples of use, are there any other tutors you could refer me to.

3. Can anyone tell me if the compiler that I am using will run the Std Aux function? If you can give me a simple program that I can vary the bits on the serial output ports, I will be able to better understand and test the results at the com port.

4. Can you also address and control the Com 2 port through some function in C.

If you have questions about this projects programing please feel free to ask.

Last edited by Light; Feb 19th, 2005 at 7:00 PM. Reason: add clarification
Light is offline   Reply With Quote
Old Feb 22nd, 2005, 5:47 AM   #2
shadowhunter
Programmer
 
shadowhunter's Avatar
 
Join Date: Dec 2004
Location: Scotland
Posts: 66
Rep Power: 4 shadowhunter is on a distinguished road
Exclamation Complex

Hi Light,
Not too sure how to help you with this one but if I think of something I will let you know as soon as possible.

Thanks for the reply to my post I think I can use it,
shadowhunter.
shadowhunter is offline   Reply With Quote
Old Feb 22nd, 2005, 3:39 PM   #3
Griz803
Newbie
 
Join Date: Jul 2004
Location: Somewhere in them thar hills
Posts: 23
Rep Power: 0 Griz803 is on a distinguished road
Well..er..hmmm..

You gave a lot of information, but I didn't see any indication of what OS you are currently trying to compile under. It sounded to me like a Win32 console vs. machines running other sort of thing. While console applications compiled under Windows(some flavor) use windows calls and routines to act like a DOS program, they aren't and never will be. For your purposes, I'd recommend one of two fixes. Either download Borland Turbo C/C++ from the Borland museum web site and use genuine DOS with the older machines to compile a program OR use Linux and the native gcc compiler to do it. Porting the code across the older flavor machines shouldn't be a big deal in either case. I have written similar code for other purposes in Borland before and would direct you toward the inport and outport functions and their closely named relatives. Hope this helps, Griz
__________________
/* Bad command or filename --- go stand in the corner */
Griz803 is offline   Reply With Quote
Old Feb 23rd, 2005, 11:57 PM   #4
Light
Newbie
 
Join Date: Feb 2005
Location: USA, Western States
Posts: 4
Rep Power: 0 Light is on a distinguished road
Hi Griz803,

Thank you for your reply,

To answer your questions, I am using win 98 OS and dropping down in to dos to run the rahide editor and DJgpp "C" compiler. Are you familiar with this public domain software? The version I am working with will only compile 32 bit machine programs. Do you know if a 16 bit version was ever released and where to find a copy of it and the tutor? If it existed, could you control the serial ports and send binary words over it?

I looked at (like a year or so ago) the Borland website and don't remember seeing any free 16 bit C programing software. Do you know for sure that it exists? If so can you provide me with a link. Do you think I can still find a tutor text ect. to work from? It sounds like you may have had experience with it in the past?

I have stopped my training on C until I can confirm that I have a programming language that will allow me to transmit binary words through the serial ports.

Since I have been unable to verify that the software I am using will allow me to do that, and acquire some sort of tutor to teach me the functions necessary, I am at an impass.

Thank you Again

Light
Light is offline   Reply With Quote
Old Feb 24th, 2005, 12:08 AM   #5
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
Light: you just have to figure out how to do it, as C most definatly can. C can do just about anything. Thats how it was designed, to make programs for everything from supercomputers to elevator controllers.
ZenMasterJG is offline   Reply With Quote
Old Feb 24th, 2005, 2:14 PM   #6
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Anything above Windows 98 and you will need to look into the MS DDSK to create an actualy driver to accomplish this task since APIs after Win98 will not allow you to gain direct access to device memory like that.

From within a console the process is very simple, you are simply just reading and writing memory locations to get the data you are looking for, since serial connections have very limited abilities you will need to modulate your data and will also need to set up a series of timers to make sure you are reading the data streams correctly (or you could use your ready-to-send ready-to-receive lines much like the TI86 calculator does to signal when the next bit is to be read/written which though slower eliminates the need to install high precision timers to monitor the data).

There are several source demos available on the internet to demonstrate this purpose, I know because I did it once (years ago so I do not remember now specifically how to do it), look up parallel port driver or serial port drivers... they both accomplish the same task through the same means, just on different memory locations.
__________________
Clifford Matthew Roche <geek@cliffordroche.com>
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:59 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC