comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Bode <m.g.bode@web.de>
Subject: Re: Ada, Com Ports and Modems
Date: 21 Mar 2003 07:51:53 +0100
Date: 2003-03-21T07:51:53+01:00	[thread overview]
Message-ID: <87wuitciuu.fsf@320025674319-0001.dialin.t-online.de> (raw)
In-Reply-To: b5c888$na2$1@sparta.btinternet.com

"Les" <les.britten@talk21.com> writes:

> I am a final year student studying at the University of Portsmouth.  I am
> trying to get Ada to communicate to my modem with query AT or ATI and get a
> response OK back..  I have tried direct_IO and sequential_IO but to no luck.

You need to use whatever functions your operating system offers for
handling the com port. Then you need Ada bindings for that functions
like these for Win32:

> I have had a look at Stephe's COM port stuff
> (http://users.erols.com/leakstan/Stephe/) 

I've just put up my own serial comm stuff which works for Linux and
Win32: http://home.t-online.de/home/michael_bode/downloads/serial_comm.tgz
It works for me but is not widely tested and reflects my own process
of learning Ada (which means it is not suitable as a textbook example
:-)).

> harder to do than I first thought.  Do I need to go though modem drivers or

If you speak of the usual Hayes comptible modem there is no such thing
as a modem driver. This is a fiction out of Redmond.

> can I just send the AT command to the COM port (witch the modem is on) and
> get the response back.

Exactly. You just need to use the right functions to send these
strings (in Windows and Linux that are the OS file I/O functions). Not
Ada.Text_Io...

> I'm not a great programmer (more of a business student) so any help, example
> code would be very grateful, and if you can keep it relatively simple I'd

Basically:

Open (Port);
Set_Parameters (Port, Baud_Rate, Parity, whatever...); -- if necessary
Write (Port, "ATZ");
Read (Port, Buffer); -- should receive "OK"
...

Close (Port);

-- 
F�r OE User: http://learn.to/quote/
OE users please read http://www.uwasa.fi/~ts/http/quote.html
PGP Key: http://home.t-online.de/home/michael_bode/
Legal Disclaimer: Wer Sarkasmus findet, darf ihn behalten.



      parent reply	other threads:[~2003-03-21  6:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-20 11:21 Ada, Com Ports and Modems Les
2003-03-20 14:31 ` abdel
2003-03-20 14:41   ` Jacob Sparre Andersen
2003-03-21  6:51 ` Michael Bode [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox