[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-bugs
Subject: [haiku-bugs] Re: [Haiku] #8789: read doesn't work for serial communication (neither bash's nor BSeri
From: "ttcoder" <trac () haiku-os ! org>
Date: 2012-07-31 19:16:52
Message-ID: 056.67c359e3325698d354cba4f0c3da43a5 () haiku-os ! org
[Download RAW message or body]
#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):
So it turns out '''SetBlocking(false) is simply not enforced''' at all.
Didn't realize that before due to the unit sending data before Read() was
first invoked and due to plain simple clumsyness on my part.
So I guess this ticket description should be worded quite differently, as
the bug is more benign than I feared. Still no good for us though, as my
tunetracker code is not structured at all for sync serial reading :-) I
really need non-blocking reading. So if non-blocking cannot be fixed
(easily/soon) I'll have to restructure my code to run in an independant
thread, and ifdef-out those changes (because BeOS build still needs non-
blocking code, otherwise it leaks memory). Anyhow here's the minimum code
to reproduce the bug I guess:
{{{
/*
gcc -ldevice miniserialtest.cpp && ./serialtest
*/
// libroot.so
#include <stdio.h>
// libdevice.so
#include <device/SerialPort.h>
int main( int argc, char ** argv )
{
printf("USB-serial test-case running (argc=%d)\n", argc);
BSerialPort mPort;
mPort.SetDataRate(B_9600_BPS);
mPort.SetDataBits(B_DATA_BITS_8);
mPort.SetStopBits(B_STOP_BITS_1);
mPort.SetParityMode(B_NO_PARITY);
mPort.SetFlowControl(B_NOFLOW_CONTROL);
mPort.SetBlocking( false );//true );
if( mPort.Open("/dev/ports/usb0") <= 0 )
{
perror( "can't open port" );
exit(0);
}
mPort.ClearInput();
mPort.ClearOutput();
char buf[2] = { 0 };
printf( "before Read()...\n" );
int numBytes = mPort.Read( buf, 1 );
printf( "after Read(), got %d...!\nOn a usb-serial device you will
only see this line after traffic gets sent to the serial port, meaning
mPort.SetBlocking( false ) is NOT enforced\n", numBytes );
}
}}}
Update:
just realized that BSerialPort::HasDatapending() might save my skin !!
(from rewriting my code to work-around the bug I mean).
--
Ticket URL: <http://dev.haiku-os.org/ticket/8789#comment:11>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic