Solved

Reading from serial port

Posted on 1999-01-21
10
562 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
ID: 1217504
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
ID: 1217505
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
ID: 1217506
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
ID: 1217507
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
ID: 1217508
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:vikiing
ID: 1217509
>>(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
ID: 1217510
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
ID: 1217511
>>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
ID: 1217512
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
ID: 1217513
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Fine Tune your automatic Updates for Ubuntu / Debian
Scenario: Your operations manager has discovered an anomaly in your security system. The business will start to suffer within 15 minutes if it is a major IT incident. What should she do? We have 6 recommendations for managing major incidents (https:…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

26 Experts available now in Live!

Get 1:1 Help Now