neoVI Green USB interface - intrepidcs API
Main
Overview
This document explains the raw USB interface for neoVI Green. This document contains all the information that is necessary to write USB drivers for neoVI Green on any operating system. neoVI Green is compatible with both USB 1.1 and USB 2.
USB Interface
The USB interface uses bulk transfers. Basically, the driver should poll the IN endpoint for data after setting alternate setting 1. To send data you will send OUT data to the out endpoint. This basic interface works just like a serial port.
* neoVI has the default control end point
* neoVI has one bulk in and one bulk out endpoint on alternate setting one. Alternate setting 0 has no endpoints.
* neoVI has code in device (does not need firmware loading over USB)
* neoVI is self powered
Bandwidth requirements
The driver should insure performance of neoVI by including a USB Bulk request in the kernel mode of the driver. User mode bulk requests occurs in a user mode thread which can be stopped for dozens of milliseconds. This dozens of milliseconds is long enough to cause the 2K buffer in neoVI to overflow at high bandwidth CAN bus loads. The transmit portion is not speed critical and can therefore stay in user mode.
Assuming worst case 100 bytes per millisecond (all eight buses at 100%) that would give 2k fifo about 20 milliseconds to fill. Therefore, if you can guarantee that the FIFO is emptied every 5 milliseconds you should have a workable design.
Use of driver
The follow lists an example usage on WIN32.
OPENING THE DRIVER
1) The application calls open method in the DLL
2) The open method calls CreateFile using (neovi-XX). XX is the index of the USB device. The driver uses a mutex to protect against two programs opening the same XX id.
3) SetAlternate setting is called to chose the setting with bulk endpoints (see code at end of email)
4) The user mode thread is started which polls the bulk in endpoint
5) A user mode thread is started which monitors a fifo and send data out to the bulk out end point when data is present
USER MODE RX THREAD
1) Code starts a loop
2) The loop monitors a stop flag protected by a critical section
3) If not stop it calls device IOCONTROL IOCTL_EZUSB_BULK_READ to get data with a buffer size of 2K
4) If neoVI doesn't have any data it will respond with a no data message (four byte sequence)
5) If neoVI has data it will fill the buffer
6) the thread sleeps for 4 ms sleep(4) and repeats loop if stop flag is not active
USER MODE TX THREAD
1) Code starts a loop
2) the code enters a critical section protecting the tx out buffer and get any txs data if present. it also reads a stop flag
3) if there is no data the thread sleeps
4) the code sends data using the send data method (code also below)
5) the code repeats if stop flag is not active
CLOSING THE DRIVER
1) both tx and rx threads are stopped using flags (they are forcefully stopped if flag method fails)
2) SetAlternateSetting is set to 0
3) CloseHandle is used to close the device
4) the mutex is used to free that port number
| intrepidcs API Documentation - (C) Copyright 2000-2012 Intrepid Control Systems, Inc. (www.intrepidcs.com) |
Last Updated : Monday, April 4, 2005