comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: ?how to read just single bit for a serial port?
Date: Sun, 14 Apr 2002 14:53:29 -0500
Date: 2002-04-14T14:53:29-05:00	[thread overview]
Message-ID: <mailman.1018814041.18837.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: ba071575.0204140625.20cc7ae8@posting.google.com

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





      parent reply	other threads:[~2002-04-14 19:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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. [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