[NTLUG:Discuss] serial communications

Stephen Davidson gorky at freenet.carleton.ca
Mon Nov 8 21:16:21 CST 2004


Hi.

This Java Guy is not going to be much help with the non-blocking stuff.  
Usually (at least in Java Land), there is a method to call _before_ 
doing the read to see if any bytes are available for reading.  The stuff 
I wrote was multi-threaded and blocking, which meant a "listener" therad 
was spun off to do the listening, and would "wake-up" whenever data was 
received.  In the case of the devices in question, one always knew when 
a message was coming in.

 From the sounds of it, somebody may have implemented the Java 
SerialComm package, or something simliar?  For using non-blocking IO, 
your code may do the trick.

Regards,
Steve

james osburn wrote:

> an how would a call to select or poll figure into this?
>
> what i have inherited is a slot machine that was written a combination
> of java and c and serial port monitor process written in c.
>
> the serial port monitor reads from the serial port and has an open
> message queue.
>
> i am originally a visuall c++ programmer and i have some exposure
> to linux and unix in college.  so getting my mind around how to use
> the serial port has been frustrating but ....
> i like your analogy about block versus non blocking.
>
> so if you use non block io ... how would then know when values are 
> available?
>
> something like this:
>
> while(1)
> {
>      int ret = read(serial_fd,buff,size);
>      if(ret > 0 )
>      {
>      do something with the received bytes
>      }
> }
>
> what about using the function select?
>
> thanks again to the group
> jim

-- 
Java/J2EE Developer/Integrator
Stephen Davidson and Associates, Inc.
Past Chair, Dallas/FortWorth J2EE Sig
214-724-7741





More information about the Discuss mailing list