[haiku-bugs] Re: [Haiku] #8789: read doesn't work for serial communication (neither bash's nor BSerialPort::Read())

  • From: "ttcoder" <trac@xxxxxxxxxxxx>
  • Date: Tue, 07 Aug 2012 20:36:00 -0000

#8789: read doesn't work for serial communication (neither bash's nor
BSerialPort::Read())
---------------------------+----------------------------
   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):

 (sorry, meant to say BSerialPort::WaitForInput()). Anyway no luck, it did
 not save the day.. Findings:

 - WaitForInput() seems to be unusable, no matter the use scenario it
 returns '''0x80000005: Invalid Argument'''
 - Looking at the headers I noticed there exists a NumCharsAvailable() too,
 but it's marked as [http://cgit.haiku-
 os.org/haiku/tree/src/kits/device/SerialPort.cpp#n396 TODO: implement]
 - Read() continues to work fairly well... but synchronously (i.e.
 blocking, even if the port is configured as SetBlocking( false))

 Now for the ''weird'' one: there seems to be a side-effect of the driver
 on my userland code of some sort; namely, an if(variable>=2) statement in
 my code is not executed despite the variable being == 2, unless I make
 neutral changes to the code adding printf()s;

 Rephrasing:

 - the first line looks like this:

 {{{
         printf("USB-serial test-case running (argc=%d)\n", argc);
 }}}

 and correctly prints "argc=2" when I pass an argument.

 YET an if() at the end of main() looking like this:

 {{{
                 if( argc >= 2 )
                 {
                         char buf[128] = { 0 };

                         puts( "Enter string to send to BT box (e.g. *0U or
 *0111 or *011A ...), followed by <enter> :" );
 }}}

 is never entered... until after I add some tracing printf()s higher-up in
 the program. Does not look like memory corruption per se. I've looked for
 beginner-style mistakes (we're all subject to misplaced semicolons when
 tired eh? :-) in my code and there's none. Go figure. Not ruling out a
 mis-communication between me & Dane though (it occured on his setup).
 Another possible theory: maybe the if() ''is'' entered but the puts()
 fails to send text to Terminal for some reason, as a side-effect of all
 the ioctl()s being executed behind the scenes, and these ioctl()s wrongs
 are righted only if peppering my code with printf() calls...

 Anyway bottom-line for now, all the doors are closing on me, except the
 rewrite-my-code-to-be-synchronous one. Dang.

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

Other related posts: