comp.lang.ada
 help / color / mirror / Atom feed
* ?how to read just single bit for a serial port?
@ 2002-04-14 14:25 Jamie
  2002-04-14 15:30 ` How " Jacob Sparre Andersen
  2002-04-14 19:53 ` ?how " David C. Hoos, Sr.
  0 siblings, 2 replies; 3+ messages in thread
From: Jamie @ 2002-04-14 14:25 UTC (permalink / raw)


Hello, 

I've got a problem with reading a single bit from serial port. what
type should I declare to store this? dose the 'character' work?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to read just single bit for a serial port?
  2002-04-14 14:25 ?how to read just single bit for a serial port? Jamie
@ 2002-04-14 15:30 ` Jacob Sparre Andersen
  2002-04-14 19:53 ` ?how " David C. Hoos, Sr.
  1 sibling, 0 replies; 3+ messages in thread
From: Jacob Sparre Andersen @ 2002-04-14 15:30 UTC (permalink / raw)


Jamie wrote:

> I've got a problem with reading a single bit from serial port. what
> type should I declare to store this? dose the 'character' work?

You should be able to find the Ada specific part of the
information in chapter 13.5 in the Ada Language Reference
Manual.

Jacob
-- 
Sk�ne Sj�lland Linux User Group - http://www.sslug.dk/
N�ste m�de: RPM og dpkg - Hold styr p� dine programmer.
Torsdag den 18. april 2002 p� Niels Bohr Institutet,
Blegdamsvej 17.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ?how to read just single bit for a serial port?
  2002-04-14 14:25 ?how to read just single bit for a serial port? Jamie
  2002-04-14 15:30 ` How " Jacob Sparre Andersen
@ 2002-04-14 19:53 ` David C. Hoos, Sr.
  1 sibling, 0 replies; 3+ messages in thread
From: David C. Hoos, Sr. @ 2002-04-14 19:53 UTC (permalink / raw)


Since the physical reads from a serial port
are eight-bit octets, you can declare a type
like this:

type bit is mod 2;
type bit_array is array (natural range 0 .. 7) of bit;

Then instantiate an instance of Unchecked_Conversion
like so:

function to_bits is new Ada.Unchecked_Conversion
  (Source : Character;
   Target : Bit_Array);

Now you can read a character from the port, convert the
character to a bit_array, then select the desired bit
from the array. 
  
----- Original Message ----- 
From: "Jamie" <kz105@student.cs.york.ac.uk>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: April 14, 2002 9:25 AM
Subject: ?how to read just single bit for a serial port?


> Hello, 
> 
> I've got a problem with reading a single bit from serial port. what
> type should I declare to store this? dose the 'character' work?
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 
> 





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-04-14 19:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-14 14:25 ?how to read just single bit for a serial port? Jamie
2002-04-14 15:30 ` How " Jacob Sparre Andersen
2002-04-14 19:53 ` ?how " David C. Hoos, Sr.

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