- 论坛徽章:
- 0
|
1. wget http://xxxx//peak-linux-driver-6.4.tar.gz
2. tar xvzf peak-linux-driver-6.4.tar.gz
3. uname -r 得到现在的linux版本号
4. 从新编译相应版本的内核,原来发现的问题可能是版本不一致或者于其他的module冲突!
5. cd peak-linux-driver-6.4
6. make clean
7. make PCC=NO_PCCARD_SUPPORT
8. make install
modprobe pcan
2007/08/17
tail -f /var/log/messasge
Aug 17 23:22:48 ding kernel: usb 2-1: new full speed USB device using uhci_hcd and address 4
Aug 17 23:22:48 ding kernel: usb 2-1: configuration #1 chosen from 1 choice
Aug 17 23:22:53 ding kernel: pcan: usb_set_configuration() failed!
Aug 17 23:22:53 ding kernel: (-110)pcan: pcan_usb_cleanup()
Aug 17 23:22:53 ding kernel: pcan: pcan_usb_plugin() failed! (-110)
Aug 17 23:22:53 ding kernel: pcan: probe of 2-1:1.0 failed with error -110
Aug 17 23:22:53 ding kernel: usb 2-1: device_add(2-1:1.0) --> -110
break point 1:
control_handler().
type=0 req=0x06 get_descriptor()
seq type req
------------
1 0 6 get_descriptor()
2 0 5 set_address()
3 0 6 get_descriptor()
4 0 6 get_descriptor()
5 0 6 get_descriptor()
6 0 9 set_configuration()
fixbus pcan_usb_plugin() failed (-110)
-110 is time out error, 导致配置没有成功! 原因是 fireware配置好后就连续的给EndPoint2发送
报文,将该功能去掉则pcan_usb_plugin() OK.
descriptor.bcdDevice.lowbyte is HardcodedDevNr
descriptor.bcdDevice.higtbyte is Revision (hardware Revision)
pcan_main.h
typedef struct
{
u16 wStepSize; // size of bytes to step to next entry 每一个单元的字节数
u16 wCopySize; // size of bytes to copy
void *bufferBegin; // points to first element
void *bufferEnd; // points to the last element
u32 nCount; // max count of elements in fifo
u32 nStored; // count of currently received and stored messages
u32 dwTotal; // received messages
void *r; // points to the next Msg to read into the read buffer
void *w; // points to the next Msg to write into read buffer
spinlock_t lock; // mutual exclusion lock
} FIFO_MANAGER;
Pcan_main.c
pcan_fifo_init(&dev->readFifo, &dev->rMsg[0], &dev->rMsg[READ_MESSAGE_COUNT - 1], READ_MESSAGE_COUNT, sizeof(TPCANRdMsg));
pcan_fifo_init(&dev->writeFifo, &dev->wMsg[0], &dev->wMsg[WRITE_MESSAGE_COUNT - 1], WRITE_MESSAGE_COUNT, sizeof(TPCANMsg) );
READ_MESSAGE_COUNT 500
WRITE_MESSAGE_COUNT 50
typedef struct
{
DWORD ID; // 11/29 bit code
BYTE MSGTYPE; // bits of MSGTYPE_*
BYTE LEN; // count of data bytes (0..8)
BYTE DATA[8]; // data bytes, up to 8
} TPCANMsg; // for PCAN_WRITE_MSG
//sizeof(TPCANMsg)= 4+1+1+8 = 14
typedef struct
{
TPCANMsg Msg; // the above message
DWORD dwTime; // a timestamp in msec, read only
WORD wUsec; // remainder in micro-seconds
} TPCANRdMsg; // for PCAN_READ_MSG
//sizeof(TPCANRdMsg)= sizeof(TPCANMsg)+4+2=20
Linux驱动:
FILL_BULK_URB(u->read_data, u->usb_dev,
usb_rcvbulkpipe(u->usb_dev, u->Endpoint[2].ucNumber),
u->pucReadBuffer[0], u->wReadBufferLength, pcan_usb_read_notify, dev);
Endpont[0]:端点1 OUT Endpont[1]:端点1 IN
Endpont[2]:端点2 OUT Endpont[3]:端点2 IN
913
/**
914
* usb_fill_bulk_urb - macro to help initialize a bulk urb
915
* @urb: pointer to the urb to initialize.
916
* @dev: pointer to the struct usb_device for this urb.
917
* @pipe: the endpoint pipe
918
* @transfer_buffer: pointer to the transfer buffer
919
* @buffer_length: length of the transfer buffer
920
* @complete: pointer to the usb_complete_t function
921
* @context: what to set the urb context to.
922
*
923
* Initializes a bulk urb with the proper information needed to submit it
924
* to a device.
925
*/
926
static inline void
usb_fill_bulk_urb
(struct
urb
*
urb
,
927
struct
usb_device
*
dev
,
928
unsigned int
pipe
,
929
void *transfer_buffer,
930
int
buffer_length
,
931
usb_complete_t
complete
,
932
void *
context
)
933
{
934
spin_lock_init
(&
urb
->
lock
);
935
urb
->
dev
=
dev
;
936
urb
->
pipe
=
pipe
;
937
urb
->transfer_buffer = transfer_buffer;
938
urb
->transfer_buffer_length =
buffer_length
;
939
urb
->
complete
=
complete
;
940
urb
->
context
=
context
;
941
}
目前把reversion改为6,这样端点2的IN/OUT每次通讯包的长度固定为64字节。
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/31891/showart_356269.html |
|