Linux universal technology-Linux technology and application information. For details, see the following section. I used a USB driver framework to rewrite a driver that communicates with the ARM Development Board, but found that reading data from the device was slow.
I took the Development Board to windows for reading. The speed is very fast and it is normal. If the Frame Rate in windows is 50 frames, I will use this driver for about 10 frames in linux!
The read code is as follows:
CODE: static ssize_t device_driver_read (struct file * filp, char * user_buffer, size_t count, loff_t * ppos)
{
Struct device_device * dev;
Int retval = 0;
Int readed_size = 0;
Int bytes_read;
Dev = (struct usb_skel *) filp-> private_data;
While (1)
{
Retval = usb_bulk_msg (dev-> device,
Usb_rcvbulkpipe (dev-> device, dev-> bulk_in_endpoint_addr ),
Dev-> bulk_in_buffer,
Dev-> bulk_in_size,
& Bytes_read, 1000 );
If (retval = 0)
{
If (readed_size + bytes_read <= count)
{
If (bytes_read> 0)
{
If (copy_to_user (user_buffer + readed_size, dev-> bulk_in_buffer, bytes_read ))
{
Err ("copy_to_use error ");
Retval =-EFAULT;
Break;
}
}
}
Readed_size + = bytes_read;
If (bytes_read <64)
{
Retval = readed_size;
Break;
}
}
Else
{
Err ("usb_bulk_msg error: % d", retval );
Break;
}
}
Return retval;
} |