Solved

Reading from serial port

Posted on 1999-01-21
10
561 Views
Last Modified: 2012-08-14
I have to process and store data that comes from a measuring instrument via serial interface (4800 baud, 8Bit, 1 Stopbit, no parity). The instrument sends the date correct, I can test this with a terminal program, the only problem is to recieve the data it sends.
Simply listening on the port only produces garbage (as expected), and I don't know how to initialize the COM port to read from it. The most specific help I have found about that topic in programming guides was "there are standard libraries for that problemn with most compilers", but neither which library nor which routines or how to use them.

The program hast to run under DOS, as we can't know which computer we will take out. For compilation I use Turbo Pascal 7.0, but there are also a Turbo-C and a Delphi compilers available. If you can help me, please send a short description of the routines, where to find them and how to use them. If all other fails, and you have some Low-Level routines, I can test them too.
Thanks in Advance
0
Comment
Question by:mdietz
  • 5
  • 4
10 Comments
 

Expert Comment

by:rosch
Comment Utility
You have that to place a program in pascal resident in memory. That he will be activated by arrived of data in the serial input that to choose. for this you needs to use the table of interrupt sees a book that describes which is the arrived interruption of  data in the serial gate. Thus that to arrive data in the serial gate its program will be activated, ok.

0
 
LVL 3

Expert Comment

by:vikiing
Comment Utility
I've developed an application like yours, a simple running program, and not a TSR.

Unfortunately, Pascal has nothing to deal adequately with serial ports; thus, I had to make all the job "manually", this is, I had to work with the PIC (Programmed Interrupt Controller), with serial ports registers and all that stuff.

With that, my application reads up to 9600 baud with no problem. Send me a mail if you want relevant code, 'cause it's to big to paste it here.
0
 
LVL 2

Author Comment

by:mdietz
Comment Utility
rosch:I was looking for the unit and the routines and something that described how. If you think I have to write a driver for the use of the serial port you have to be more specific than that.

vikiing: I've got some description of the port and the corresponding interrupt 14 from friends, I will test if that's enough, else I'll leave a note here or contact you.
0
 
LVL 3

Expert Comment

by:vikiing
Comment Utility
Int 14 serves only to initialize serial port, but not for I/O transfer itself, which must be accomplished by an interrupt routine and another stuff.

0
 
LVL 2

Author Comment

by:mdietz
Comment Utility
After initializing the the serial port for the correct transfer protocol (baud, parity and so on) the com status register can be asked and a transfer based on this info is easily programmed (without writing own interrupt routines). It seems the only problem was to initialize the com port at the start, that the Status register and serial port showed such strange values...

Thanks anyway to all who helped me, I'll delete this question in a few days
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 3

Expert Comment

by:vikiing
Comment Utility
>>(without writing own interrupt routines).

That's true if you handle com port under a "programmed I/O" scheme. With that, you read data at the moment you need it (and when you know it's present at port).

But if your instrument generates data which arrive to port while YOU'RE NOT waiting for them, then you must write an interrupt routine in order to not loose the unsolicited input.

0
 
LVL 2

Author Comment

by:mdietz
Comment Utility
I programmed a blind sending/dumb listening (the receiver waits until a defined "start" character is transferred and then stores the input to disk until the sender sends a defined "stop" character. This should have be working, as I can tell the instrument when to send, but it seems that somewhere in the transfer some bytes disappeared and the remaining data was useless after the byte positions were mixed up.
If you can send your routines to handle that problem to martin@rbg.informatik.tu-darmstadt.de I will test them, and if they can solve the problem
you get the points.
0
 
LVL 3

Expert Comment

by:vikiing
Comment Utility
>>it seems that somewhere in the transfer some bytes disappeared

I supose it occurs because the instrument is sending data at a moment in which you're not listening to the port. That's why you need an interrupt procedure which catches all coming bytes, no matter what the rest of the program is doing. I'll prepare the things to mail you.
0
 
LVL 3

Accepted Solution

by:
vikiing earned 50 total points
Comment Utility
I have sent a mail to Mdietz with the routines, and he found them useful for his job.

I anybody wants them, just only put a mail.

0
 
LVL 2

Author Comment

by:mdietz
Comment Utility
Thanks
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Veeam Backup & Replication has added a new integration – Veeam Backup for Microsoft Office 365.  In this blog, we will discuss how you can benefit from Office 365 email backup with the Veeam’s new product and try to shed some light on the needs and …
A procedure for exporting installed hotfix details of remote computers using powershell
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now