[USB DDK] usbd_urb_status == EBUSY forever

bridged with qnx.ddk
Post Reply
Fred P.

[USB DDK] usbd_urb_status == EBUSY forever

Post by Fred P. » Tue Jul 06, 2004 11:36 pm

Hi everyone,

I'm writing a USB device driver for an FTDI USB->Serial chip:
[0x6001,0x0403],
http://www.ftdichip.com/ based on the USB DDK Printer driver example,
since it has bulk in/out and some control setup.

I'm able to make the test LED going on and off
to the serial test board plugged to the FTDI in bitbang mode,
but usbd_urb_status == EBUSY and never return.

If I skip the bulk_wait part, I'm able to send data packets of 64 bytes to
the FTDI target,
but I'm unable to read anything.

bulk_cbf() is called only when I press CTRL-C, if I leave the bulk_wait().

Basically, I send a 5 bytes packet with the following decimal values
[18,27,68,18,69]
and I should retrieve a 2 bytes packet with the following decimal values
[71,13]
from a "pure serial port" point of view.

For instance, I'm getting the following decimal values in my usbd_alloc(64)
read_data:
[33,96,144, 71,141,0...] or [0,0,0, 0,0,0...] garbage
instead of [71,13,0, 0,0,0...]

# io-usb -duhci
# usb -vvv
USB 0 (UHCI) v1.10, v1.01 DDK, v1.01 HCD
Control, Interrupt, Bulk, Isoch, Low speed

Device Address : 1
Upstream Host Controller : 0
Upstream Device Address : 0
Upstream Port : 0
Upstream Port Speed : Full
Vendor : 0x0403
Product : 0x6001
Device Release : r2.00
USB Spec Release : v1.10
Serial Number : N/A
Class : 0x00 (Independant per interface)
Max PacketSize0 : 8
Languages : No string descriptors
Current Frame : 929 (1024 bytes)
Configurations : 1
Configuration : 1
Attributes : 0x80 (Bus-powered)
Max Power : 90 mA
Interfaces : 1
Interface : 0 / 0
Class : 0xff (Vendor-specific)
Subclass : 0xff
Protocol : 0xff
Endpoints : Control + 2
Endpoint : 0
Attributes : Control
Max Packet Size: 8
Endpoint : 1
Attributes : Bulk/IN
Max Packet Size: 64
Endpoint : 2
Attributes : Bulk/OUT
Max Packet Size: 64

=================

program with fprintf log file for bulk_wait() enabled code:

inserted [8055f20][8055f8c]
{
devno 1 inserted
Read #0 = NULL
{
bLength[12],bDescriptorType[1],bcdUSB[110],bDeviceClass[0],
bDeviceSubClass[0],bDeviceProtocol[0],bMaxPacketSize0[8],
idVendor[403],idProduct[6001],bcdDevice[200],iManufacturer[1],
iProduct[2],iSerialNumber[3],bNumConfigurations[1]
}
Found CONTROL LINE - EndPoint#[0] - Max Packet Size [8]
Control pipe opened
Found BULK - EndPoint#[1]
BULK IN - Max Packet Size [64]
Input pipe opened
Found BULK - EndPoint#[2]
BULK OUT - Max Packet Size [64]
Output pipe opened
parse successful
Do something...
Initializing FTDI structure
Opening a FTDI device
usb_control_msg: setup...
urb[805a014], flags[2], request[0], request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]usb_control_msg: setup...
urb[805a014], flags[2], request[3], request_type[40],value[4138], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]ftdi open succeeded: 0
enabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[1ff], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]sleep 1 seconds...
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Inside sleepon_lock()
usb_bulk_wait: Inside while... sleepon_wait()
usb_bulk_wait: urb_status[10],status[0],len[0],EBUSY[10]
]
{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[] LENGTH[5]
{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[5]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[5]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
sleep 1 seconds...

disabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]insertion: closed.

=================

program with fprintf log file for bulk_wait() disabled code:

inserted [8055f20][8055f8c]
{
devno 1 inserted
Read #0 = NULL
{
bLength[12],bDescriptorType[1],bcdUSB[110],bDeviceClass[0],
bDeviceSubClass[0],bDeviceProtocol[0],bMaxPacketSize0[8],
idVendor[403],idProduct[6001],bcdDevice[200],iManufacturer[1],
iProduct[2],iSerialNumber[3],bNumConfigurations[1]
}
Found CONTROL LINE - EndPoint#[0] - Max Packet Size [8]
Control pipe opened
Found BULK - EndPoint#[1]
BULK IN - Max Packet Size [64]
Input pipe opened
Found BULK - EndPoint#[2]
BULK OUT - Max Packet Size [64]
Output pipe opened
parse successful
Do something...
Initializing FTDI structure
Opening a FTDI device
usb_control_msg: setup...
urb[805a014], flags[2], request[0], request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]usb_control_msg: setup...
urb[805a014], flags[2], request[3], request_type[40],value[4138], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]ftdi open succeeded: 0
enabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[1ff], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]sleep 1 seconds...
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[] LENGTH[5]
{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[] LENGTH[5]
{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[5]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[5]
{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]
{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x90][144][É],[0x0][0][_],[0x0][0][_],[0x0][0][_
],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]
{[0x21][33][!],[0x0][0][_],[0x90][144][É],[0x0][0][_],[0x0][0][_],[0x0][0][_
],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
sleep 1 seconds...

disabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]insertion: closed.

=========================

Anyone has any idea of what the problem could be ?!

Sincerely yours,
Fred.

Fred P.

Re: [USB DDK] usbd_urb_status == EBUSY forever

Post by Fred P. » Tue Jul 06, 2004 11:56 pm

I also tried with 3 different urbs instead of just 1 urb:
urb_ctrl, urb_in, urb_out
for each endpoint, still gives EBUSY forever.

Based on the suggestion made by "Henry VanDyke"
in "Serial-USB driver help Belikn F5U103".

Sincerely,
Fred.

Hi everyone,

I'm writing a USB device driver for an FTDI USB->Serial chip:
[0x6001,0x0403],
http://www.ftdichip.com/ based on the USB DDK Printer driver example,
since it has bulk in/out and some control setup.

I'm able to make the test LED going on and off
to the serial test board plugged to the FTDI in bitbang mode,
but usbd_urb_status == EBUSY and never return.

If I skip the bulk_wait part, I'm able to send data packets of 64 bytes to
the FTDI target,
but I'm unable to read anything.

bulk_cbf() is called only when I press CTRL-C, if I leave the bulk_wait().

Basically, I send a 5 bytes packet with the following decimal values
[18,27,68,18,69]
and I should retrieve a 2 bytes packet with the following decimal values
[71,13]
from a "pure serial port" point of view.

For instance, I'm getting the following decimal values in my
usbd_alloc(64)
read_data:
[33,96,144, 71,141,0...] or [0,0,0, 0,0,0...] garbage
instead of [71,13,0, 0,0,0...]

# io-usb -duhci
# usb -vvv
USB 0 (UHCI) v1.10, v1.01 DDK, v1.01 HCD
Control, Interrupt, Bulk, Isoch, Low speed

Device Address : 1
Upstream Host Controller : 0
Upstream Device Address : 0
Upstream Port : 0
Upstream Port Speed : Full
Vendor : 0x0403
Product : 0x6001
Device Release : r2.00
USB Spec Release : v1.10
Serial Number : N/A
Class : 0x00 (Independant per interface)
Max PacketSize0 : 8
Languages : No string descriptors
Current Frame : 929 (1024 bytes)
Configurations : 1
Configuration : 1
Attributes : 0x80 (Bus-powered)
Max Power : 90 mA
Interfaces : 1
Interface : 0 / 0
Class : 0xff (Vendor-specific)
Subclass : 0xff
Protocol : 0xff
Endpoints : Control + 2
Endpoint : 0
Attributes : Control
Max Packet Size: 8
Endpoint : 1
Attributes : Bulk/IN
Max Packet Size: 64
Endpoint : 2
Attributes : Bulk/OUT
Max Packet Size: 64

=================

program with fprintf log file for bulk_wait() enabled code:

inserted [8055f20][8055f8c]
{
devno 1 inserted
Read #0 = NULL
{
bLength[12],bDescriptorType[1],bcdUSB[110],bDeviceClass[0],
bDeviceSubClass[0],bDeviceProtocol[0],bMaxPacketSize0[8],
idVendor[403],idProduct[6001],bcdDevice[200],iManufacturer[1],
iProduct[2],iSerialNumber[3],bNumConfigurations[1]
}
Found CONTROL LINE - EndPoint#[0] - Max Packet Size [8]
Control pipe opened
Found BULK - EndPoint#[1]
BULK IN - Max Packet Size [64]
Input pipe opened
Found BULK - EndPoint#[2]
BULK OUT - Max Packet Size [64]
Output pipe opened
parse successful
Do something...
Initializing FTDI structure
Opening a FTDI device
usb_control_msg: setup...
urb[805a014], flags[2], request[0], request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]usb_control_msg: setup...
urb[805a014], flags[2], request[3], request_type[40],value[4138],
index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]ftdi open succeeded: 0
enabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[1ff], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]sleep 1 seconds...
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Inside sleepon_lock()
usb_bulk_wait: Inside while... sleepon_wait()
usb_bulk_wait: urb_status[10],status[0],len[0],EBUSY[10]
]

{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[] LENGTH[5]

{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[5]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[5]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
sleep 1 seconds...

disabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]insertion: closed.

=================

program with fprintf log file for bulk_wait() disabled code:

inserted [8055f20][8055f8c]
{
devno 1 inserted
Read #0 = NULL
{
bLength[12],bDescriptorType[1],bcdUSB[110],bDeviceClass[0],
bDeviceSubClass[0],bDeviceProtocol[0],bMaxPacketSize0[8],
idVendor[403],idProduct[6001],bcdDevice[200],iManufacturer[1],
iProduct[2],iSerialNumber[3],bNumConfigurations[1]
}
Found CONTROL LINE - EndPoint#[0] - Max Packet Size [8]
Control pipe opened
Found BULK - EndPoint#[1]
BULK IN - Max Packet Size [64]
Input pipe opened
Found BULK - EndPoint#[2]
BULK OUT - Max Packet Size [64]
Output pipe opened
parse successful
Do something...
Initializing FTDI structure
Opening a FTDI device
usb_control_msg: setup...
urb[805a014], flags[2], request[0], request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]usb_control_msg: setup...
urb[805a014], flags[2], request[3], request_type[40],value[4138],
index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]ftdi open succeeded: 0
enabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[1ff], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]sleep 1 seconds...
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[] LENGTH[5]

{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[] LENGTH[5]

{[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x
0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
disabling = Red Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCD^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x44][68][D],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[5]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[5]

{[0x21][33][!],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[0x0][0][_],[
0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
enabling = Green Light
usb_bulk_write: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[^R^ESCE^RE] LENGTH[5]

{[0x12][18][_],[0x1b][27][_],[0x45][69][E],[0x12][18][_],[0x45][69][E],[0x0]
[0][_],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
usb_bulk_read: bulk_io...
usb_bulk_io
usb_bulk_io: usbd_setup_bulk
usb_bulk_io: BEFORE BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x90][144][É],[0x0][0][_],[0x0][0][_],[0x0][0][_
],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io
usb_bulk_io: AFTER BUFFER[!] LENGTH[2]

{[0x21][33][!],[0x0][0][_],[0x90][144][É],[0x0][0][_],[0x0][0][_],[0x0][0][_
],[0x0][0][_],[0x0][0][_],}
usb_bulk_io: usbd_io: if(status[0]) bulk_wait...
usb_bulk_wait
usb_bulk_wait: Checking status[0].
sleep 1 seconds...

disabling bitbang mode
usb_control_msg: setup...
urb[805a014], flags[2], request, request_type[40],value[0], index[0],
size[0], timeout[5000]
BYTES[0]=NULL or size[0]=0
CTRL_STATUS1[0]CTRL_STATUS2[0]insertion: closed.

=========================

Anyone has any idea of what the problem could be ?!

Sincerely yours,
Fred.







Harald KL

Re: [USB DDK] FTDI USB->Serial chip

Post by Harald KL » Thu Aug 05, 2004 12:01 pm

Hello Fred,
I've got exactly the same task, and had a similar problem.
I used the printer class from the DDK as an template, too. And for the
interface description i used the Linux-Driver found on
http://ftdi-usb-sio.sourceforge.net/.
I could write to the port, but only once. And after that the message
repeated for ever and i got an EBUSY for the URB. I figured out that this
was happening because of the close statement. I did not delete the
termination code for the printer. This sent a 0 to the out-Endpoint. After
removing this writing worked properly. Still I had some trouble with
reading from the port. I found that you should not use a smaller request
then around 16 bytes. I don't know why, but when attempting to read a
smaller amount of data i get an USBD_STATUS_CMP_ERR.
You have to omit the first to bytes, too. Because they contain some status
information.
I'm quite a newbie to USB - Programming, but my driver seems to be working
now quite well. I can set the baudrate, stopbits and parity via stty.
Reading and writing works pretty much the same as on a normal serial port.

However I'm not using the bitbang mode.

If anyone has a clue on the 16-byte minimal reading problem, please let me
know.

Have fun,
Harald


Fred P. wrote:
I also tried with 3 different urbs instead of just 1 urb:
urb_ctrl, urb_in, urb_out
for each endpoint, still gives EBUSY forever.

Based on the suggestion made by "Henry VanDyke"
in "Serial-USB driver help Belikn F5U103".

Sincerely,
Fred.
Hi everyone,

I'm writing a USB device driver for an FTDI USB->Serial chip:
[0x6001,0x0403],
http://www.ftdichip.com/ based on the USB DDK Printer driver example,
since it has bulk in/out and some control setup.

I'm able to make the test LED going on and off
to the serial test board plugged to the FTDI in bitbang mode,
but usbd_urb_status == EBUSY and never return.

If I skip the bulk_wait part, I'm able to send data packets of 64 bytes to
the FTDI target,
but I'm unable to read anything.

bulk_cbf() is called only when I press CTRL-C, if I leave the bulk_wait().

Basically, I send a 5 bytes packet with the following decimal values
[18,27,68,18,69]
and I should retrieve a 2 bytes packet with the following decimal values
[71,13]
from a "pure serial port" point of view.

For instance, I'm getting the following decimal values in my
usbd_alloc(64)
read_data:
[33,96,144, 71,141,0...] or [0,0,0, 0,0,0...] garbage
instead of [71,13,0, 0,0,0...]

anthony

(usb-serial driver)-for Herald

Post by anthony » Thu Jan 06, 2005 7:58 am

hello Herald
i have seen your reply to Fred.i am facing lots of
problem in implementing read & write.i am following Linux Code as
well as the ddk-printer & ddk-mouse.can u please help me out by
sending some parts of your code to me.

please give a reply to me

take care
bye
anthony

Olena

RE: (usb-serial driver)-for Herald

Post by Olena » Thu Mar 03, 2005 10:02 am

Hello, Harald!
I`ve two similar problems with reading data from FTDI USB-Serial
chip.

1. usbd_urb_status == EBUSY forever
usbd_urb_status always returns EBUSY flag.
I can change that status only by repluging(!) FTDI device.
Would you be such kind to send some example of your code to me or
point
me where my code is wrong.

=====a part of ftdi-reading code (error-checking skiped)========
void insertion(...){
usbd_attach(...);
ep_in = usbd_endpoint_descriptor( device, 1,0,0,0x81, &DescNode
);
usbd_descriptors_t *_ep_in =
reinterpret_cast<usbd_descriptors_t*>(ep_in);
usbd_open_pipe( device, _ep_in, &InPipe );
IUSBBuf = static_cast<unsigned char*>(
usbd_alloc(IUSBBufSize) );
IURB = usbd_alloc_urb(0);
}

int pl_bulk_wait(struct usbd_urb *urb, struct usbd_pipe *pipe ) {
while(usbd_urb_status( urb, &ustatus, &alen ) == EBUSY )
{
pthread_sleepon_wait( urb );
usbd_urb_status( urb, &ustatus, &alen );
}
pthread_sleepon_unlock();
if( ( ustatus & USBD_USB_STATUS_MASK ) == USBD_STATUS_STALL )
status=usbd_reset_pipe( pipe ); puts("bulk wait> stall
error");
else{
if( (ustatus&USBD_STATUS_CMP) &&
!(ustatus&USBD_STATUS_CMP_ERR) ){
for( int i=2;i<IUSBBufSize;i++)
printf("%lx ",IUSBBuf);
}
}
}

void main(){
usbd_connect(...);
sleep(4);
memset(IUSBBuf, 0x00, 18);
for (i = 0; i < 0xFFFFFFF; i++) {
usbd_setup_bulk( IURB, URB_DIR_IN, IUSBBuf,18);
if (usbd_io(IURB, InPipe, &pl_bulk_cbf,
NULL,USBD_TIME_INFINITY)==EOK)
pl_bulk_wait( IURB, InPipe );
else { cout << "usbd_io error"; THROW_ER(r); }
}
}
===========================================
To All: Does any body knows where the problem can be?

2. About the problem with reading less than 16 bytes from devices.
IMHO you can`t read less than 16 bytes long. Because minimal packet
size is 16 bytes long (in this context).
For example I have:
D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12 D13 D14 D15 D16
1 40 0 ff bc 8 0 0 0 0 0 0 0
0 c6 ff
alen=18, where
D1-D2 -id of packet;
D3-D5 - some vendor data;
D6 - length of data transfer;
D7-D14 - data;
D15-D16 - crc.

Best regards, Olena.
mailto: norisnom@gmail.com

Olena

RE: (usb-serial driver)-for Herald

Post by Olena » Thu Mar 03, 2005 10:02 am

sorry, in code chapter I meen:
memset(IUSBBuf, 0x00, IUSBBufSize ) ; ....
usbd_setup_bulk( IURB, URB_DIR_IN, IUSBBuf, IUSBBufSize ) ;
//IUSBBufSize=18
....

Augustin

RE: (usb-serial driver)-for Herald

Post by Augustin » Tue Oct 03, 2006 3:50 pm

Hi,
I am having the same problem : EBUSY on usbd_urb_status call using the
printer template
Did anyone solve this ?

jiv

re:[USB DDK] usbd_urb_status == EBUSY forever

Post by jiv » Mon Oct 16, 2006 9:58 am

QNX versions? update patches? etc?
Using printer DDK(IMHO) -> as sample only

duttn

EBUSY forever

Post by duttn » Mon Jul 16, 2007 7:48 pm

Hi all,

I just saw this post and did not see if anybody finally solved this
problem, could somebody please let me know if this was solved, and if
possible, please attach the code as well.

Thank you so much in advance.

Regards,
N

Post Reply

Return to “qnx.ddk”