[haiku-bugs] Re: [Haiku] #8789: [USB serial] only performs BSerialPort::Read() in 'blocking' mode (was: read doesn't work for serial communication (neither bash's nor BSerialPort::Read()))

  • From: "ttcoder" <trac@xxxxxxxxxxxx>
  • Date: Fri, 10 Aug 2012 18:50:24 -0000

#8789: [USB serial] only performs BSerialPort::Read() in 'blocking' mode
---------------------------+----------------------------
   Reporter:  dsuden       |      Owner:  mmlr
       Type:  bug          |     Status:  new
   Priority:  normal       |  Milestone:  R1
  Component:  Drivers/USB  |    Version:  R1/Development
 Resolution:               |   Keywords:
 Blocked By:               |   Blocking:
Has a Patch:  0            |   Platform:  x86
---------------------------+----------------------------

Comment (by ttcoder):

 Whew! Found a successful '''work-around'''. I simply add this after
 ffd=port.Open():

 {{{
 #ifdef __HAIKU__
         int flags = fcntl( ffd, F_GETFL );
         fcntl( ffd, F_SETFL, flags | O_NONBLOCK );
 #endif
 }}}

 I got the idea while reading the SerialPort.cpp implementation. This fixes
 both the serial-test-case outlined above, and tunetracker itself: the
 Read() calls are now non-blocking, everything works as it should.

 Also had to make my code more flexible for parsing lines, since the USB-
 serial driver appears to convert some \r to \n and vice-versa, for some
 reason.

 Now we're back in business. This ticket can be set to low priority if
 nobody else needs it to be fixed.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/8789#comment:13>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts:

  • » [haiku-bugs] Re: [Haiku] #8789: [USB serial] only performs BSerialPort::Read() in 'blocking' mode (was: read doesn't work for serial communication (neither bash's nor BSerialPort::Read())) - ttcoder