|
Tài trợ cho PIC Vietnam |
Giao tiếp USB, CAN, I2C, SPI, USART... Những giao tiếp được tích hợp trên PIC |
|
Ðiều Chỉnh | Xếp Bài |
27-03-2011, 11:28 PM | #16 |
Nhập môn đệ tử
Tham gia ngày: Apr 2010
Bài gửi: 2
: |
Em là mem mới, các anh cho em hỏi, trong firmware mình muốn gửi một mảng int8 lên PC qua USB thì dùng hàm usb_puts như thế nào hay nếu dùng vòng for cho hàm usb_put_packet thì thời gian timeout thế nào? Và trong hàm UsbPipeTransferAsync này thì thời gian timeout có ý nghĩa gì?
Em đã dùng vòng for cho hàm usb_put_packet và vòng for cho hàm nhận trên C# thì thấy kết quả ra textbox lúc đúng lúc sai. Đây là code C#: private void button2_Click(object sender, EventArgs e) { for(i=0;i<9;i++) { SingleReceiver(); Application.DoEvents(); } } private void SingleReceiver() { DWORD dwBuffSize = 1; byte[] buffer = new byte[1]; textBox1.Text = ""; usb_pipe_rev.UsbPipeTransferAsync(true, 0, buffer,dwBuffSize, TIME_OUT, new D_USER_TRANSFER_COMPLETION(Transfer_rev_Completion )); } private void Transfer_rev_Completion(MRMU_1WIRE_Pipe pipe) { byte[] buff; if (pipe.GetTransferStatus() == (DWORD)wdu_err.WD_STATUS_SUCCESS) { TraceMsg(DisplayHexBuffer(pipe.GetBuffer(),1)); } else { TraceMsg("Receiver failure!\n\r"); } } Thank! |
|
|