On Wed, 20 Jun 2001, Wai-Sun Chia wrote:
> Hello Rubyists,
> Some queries on serial comm:
> 1. How do I set up the serial port to communicate with another serial 
> devices? i.e. baudrate, parity, etc.

You are looking for <termios.h>. Unfortunately that interface is much more
effort bridging to Ruby, because you need some C code. Ironically it's
because of the portable interface for accessing serial ports.

> 2. I noticed that the IO class can only do canonical processing (i.e. by 
> line). How about non-canonical (raw-mode)?

That means playing with the ICANON flag, which means you'll have to
support it, and tcsetattr(), from <termios.h>.

> I'd really hate to go back to 'C' after discovering the joys of 
> Ruby..ugh. :-/

Well, you'd only need to go back for a few pages of C. However it's better
to know <termios.h> beforehand, and know some of the Ruby<->C bridge.

After that you'll have to make decisions, like how struct termios maps to
Termios objects: copy upon crossing C/Ruby limit; or make Termios wrap
struct termios; or just don't make a Termios object, and handle everything
through methods...

matju