USB Prolific PL2303 driver (USB - serial adapter)

Hello,
I have some troubles in developing USB driver for PL2303, the sourcecode
of Linux driver here:
http://mariner.cs.ucdavis.edu/linuxsrc/source/drivers/usb/serial/pl2303.c
I trying to configure/send the stream by following source, but i can’t
get nothing at serial output, maybe i’m doing something wrong?

#include “usbd.h”

#define ID_VENDOR 0x067b
#define ID_PRODUCT 0x2303

#define DEBUG_LOG(x) printf(x)

#define VENDOR_WRITE_REQUEST_TYPE 0x40
#define VENDOR_WRITE_REQUEST 0x01

#define VENDOR_READ_REQUEST_TYPE 0xc0
#define VENDOR_READ_REQUEST 0x01

#define SET_LINE_REQUEST_TYPE 0x21
#define SET_LINE_REQUEST 0x20

#define SET_CONTROL_REQUEST_TYPE 0x21
#define SET_CONTROL_REQUEST 0x22

struct usbd_device *device = NULL;

static usbd_device_ident_t devident = {
ID_VENDOR,
ID_PRODUCT,
USBD_CONNECT_WILDCARD,
USBD_CONNECT_WILDCARD,
USBD_CONNECT_WILDCARD
};

static usbd_funcs_t funcs = {
_USBDI_NFUNCS,
insertion,
removal,
NULL
};

void insertion ( struct usbd_connection *connection, usbd_device_instance_t
*instance) {
printf(“insertion ok!\n”);
if (device == NULL ) {
if (usbd_attach(connection, instance, 0, &device) != EOK) {
fprintf(stderr, “unable to attach!\n”);
exit(1);
} else {
printf(“attach ok!\n”);
}
} else {
printf(“already attached!\n”) ;
}
}

void removal ( struct usbd_connection *connection, usbd_device_instance_t
*instance) {
if (device != NULL) {
if (usbd_detach(device) == EOK) {
printf(“detach ok!\n”);
} else {
printf(“detach failed!\n”);
}
} else {
printf(“already detached!\n”);
}
}

int main( int argc, char *argv[] )
{
usbd_connect_parm_t cparms = {
NULL,
USB_VERSION,
USBD_VERSION,
0,
argc,
argv,
0,
&devident,
&funcs,
USBD_CONNECT_WAIT
};

struct usbd_connection *connection;
struct usbd_urb *urb;
struct usbd_pipe *pipe;
struct usbd_desc_node *node;
usbd_descriptors_t *descriptors;

unsigned char *buffer;

unsigned char *buffer7;
unsigned char *buffer10;
unsigned char *buffer256;

char *send;

DEBUG_LOG(“Connecting…”);
if (usbd_connect(&cparms, &connection) == EOK) {
printf(“ok\n”);
} else {
printf(“fault\n”);
}

sleep(2);

DEBUG_LOG(“Allocating URB…”);
urb = usbd_alloc_urb(NULL);
if (urb == NULL) {
printf(“unable to allocate URB\n”);
} else {
printf(“success\n”);
}

DEBUG_LOG(“Allocating buffer…”);
buffer = (unsigned char* )usbd_alloc(4096);
if (buffer == NULL) {
printf(“unable to allocate buffer\n”);
} else {
printf(“success\n”);
}

DEBUG_LOG(“Checking device…”);
if (device == NULL) {
printf(“device error\n”);
} else {
printf(“ok\n”);
}

DEBUG_LOG(“Parsing descriptors…”);
descriptors = usbd_parse_descriptors(device, NULL, USB_DESC_DEVICE, 0,
&node);
if (descriptors == NULL) {
printf(“parsing error\n”);
} else {
printf(“ok\n”);
}

usbd_open_pipe(device, descriptors, &pipe);

int result;
#define FISH(a,b,c,d) result = usbd_setup_vendor(urb, URB_DIR_IN, b, a, c,
d, buffer, 1)
#define SOUP(a,b,c,d) result = usbd_setup_vendor(urb, URB_DIR_OUT, b, a, c,
d, NULL, 0)

DEBUG_LOG(“Sending…\n”);

FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 0);
FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0);
FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 1);
FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0);
SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0, 1);
SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 1, 0xc0);
SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 4);


buffer7 = (unsigned char* )malloc(7);
buffer10 = (unsigned char* )malloc(10);
buffer256 = (unsigned char*)malloc(256);

buffer[0] = 0x80;
buffer[1] = 0x25;
buffer[2] = 0x00;
buffer[3] = 0x00;
buffer[4] = 0x00;
buffer[5] = 0x00;
buffer[6] = 0x08; //this is a control setup buffer 19200, no parity,
databits 8, stopbits 1

#define CONTROL(u, d, r, rt, val, ind, addr, size) result =
usbd_setup_vendor(u, d, r, rt, val, ind, addr, size)

CONTROL(urb, URB_DIR_OUT, SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE, 0, 0,
buffer7, 7);
CONTROL(urb, URB_DIR_OUT, SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, 0,
0, 0, 0);
CONTROL(urb, URB_DIR_OUT, SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, 0,
0, 0, 0);
CONTROL(urb, URB_DIR_OUT, SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE, 0, 0,
buffer7, 7);


usbd_reset_pipe(pipe);


memset(buffer10, 0x00, 10);
memset(buffer256, 0x00, 256) ;

usbd_setup_bulk(urb, URB_DIR_OUT, buffer10, 10);
usbd_io(urb, pipe, NULL, NULL, USBD_TIME_INFINITY);
usbd_reset_pipe(pipe);
usbd_setup_bulk(urb, URB_DIR_OUT, buffer256, 256);
usbd_io(urb, pipe, NULL, NULL, USBD_TIME_INFINITY);


int i;
for (i = 0; i < 0xFFFFFFF; i++) {
buffer256[0] = (unsigned char)i;
usbd_setup_bulk(urb, URB_DIR_OUT, buffer256,1);
usbd_io(urb, pipe, NULL, NULL, USBD_TIME_INFINITY);
}

}