Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reading from serial port

Posted on 1999-01-21
10
Medium Priority
?
570 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
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
 
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 150 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Check out what's been happening in the Experts Exchange community.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

721 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