This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

second USB CDC hangs

Greetings,

From the sample program provided by Keil, and through the use of various websites especially http://www.keil.com/forum/15274/ I've created a program that is able to sniff out data from the USB2Serial Converter.
It then detects whether the information is usable and if so it stores it's data.

The problem I'm facing is that I can send the data perfectly through one Virtual Com Port. However when I want to review the data that has been 'sniffed' out by sending the sniffed data through the second virtual com port, the device hangs after two requests. These request are being made in the endpoint 5 event in USBUSER.c. During the first two requests it does send its information.
I have described the end points in the USB descriptor file as described by Tsuneo Chinzei on the before mentioned page of Keil.

I had to include the End point in the USB CDC in the USBCORE.c file to be accepted on the PC, else it would just say that the device is not responding when trying to connect to that COM port.

The code below will handle the storage, and reading of the sniffed data.
*RefData will be the pointer to the sniffed data
Value will indicate what will be read
ReadWrite will indicate whether or not the data ought to be stored or read
Position will determine which position it will take in the database.
The Program ain't complete, but the main goal will be to sniff out GPS data provided by a novatel device.

void ReferenceDatabase(char Value, unsigned char *RefData, char ReadWrite, char Position) {
        static TDatabaseData ReferenceDatabase[40];
        static char PassCounter=0;

        switch(ReadWrite) {
        case(WRITE_):
          if (PhotoPosition){
             if( PassCounter>39 )PassCounter=0;
               memcpy(ReferenceDatabase[PassCounter].Latitude,  RefData,sizeof(double));
              RefData+= 8;
              memcpy(ReferenceDatabase[PassCounter].Longitude, RefData,sizeof(double));
              RefData+= 8;
              memcpy(ReferenceDatabase[PassCounter].Height,    RefData,sizeof(double));
              RefData+= 8;
              memcpy(ReferenceDatabase[PassCounter].Bearing,   RefData,sizeof(double));
              PassCounter++;
              }
           else {
              LastPosition = CurrentPosition;
              memcpy(CurrentPosition.Latitude,  RefData, sizeof(double));
              RefData+= 8;
              memcpy(CurrentPosition.Longitude, RefData, sizeof(double));
              RefData+= 8;
              memcpy(CurrentPosition.Height,      RefData, sizeof(double));
              RefData+= 8;
              memcpy(CurrentPosition.Bearing,   RefData, sizeof(double));
              PassCounter++;
              }
        break;
        case(READ_):
            switch(Value){
               case(BEARING_):
                USB_WriteEP(CDC_DEP_IN1, &ReferenceDatabase[Position].Bearing[0], 8);
                break;
               case(HEIGHT_):
                USB_WriteEP(CDC_DEP_IN1, &ReferenceDatabase[Position].Height[0], 8);
                break;
               case(LONGITUDE_):
                 USB_WriteEP(CDC_DEP_IN1, &ReferenceDatabase[Position].Longitude[0], 8);
                break;
               case(LATITUDE_):
                USB_WriteEP(CDC_DEP_IN1, &ReferenceDatabase[Position].Latitude[0], 8);
                break;
                }
             break;
           }
}

This can be done when I write the reference to this function from the Main, however when referred to from the USB endpoint the device hangs after two requests.

This is the INF file written to work under windows XP and windows 7

;
; Keil - An ARM Company  Communication Device Class driver installation file
; (C)2007-2008 Copyright
;

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%Keil%
DriverVer=01/06/07
; CatalogFile=mcb2300-vcom.cat

[Manufacturer]
%Keil%=DeviceList,ntamd64

;-----------------------------------------------------------------------------
;   Device List
;-----------------------------------------------------------------------------


[DeviceList]
%DESCRIPTION%=MCB2300USB, USB\VID_c251&PID_1705
%COMPOSITE%  =MCB2300USB, USB\VID_FF00&PID_0300&MI_00, USB\VID_FF00&PID_0300&MI_02

[DeviceList.ntamd64]
%DESCRIPTION%=MCB2300USB, USB\VID_c251&PID_1705
%COMPOSITE%  =MCB2300USB, USB\VID_FF00&PID_0300&MI_00, USB\VID_FF00&PID_0300&MI_02

;------------------------------------------------------------------------------
;  Windows 2000/XP Sections
;------------------------------------------------------------------------------


[SourceDisksFiles]
;;; blank space

[SourceDisksNames]
;;; blank space


[DestinationDirs]
FakeModemCopyFileSection=12
DefaultDestDir=12

[MCB2300USB]
include=mdmcpq.inf
CopyFiles=FakeModemCopyFileSection
AddReg=MCB2300USB.AddReg

[MCB2300USB.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,usbser.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[MCB2300USB.Services]
;;add removed MCB2300USB.NT.Services for testing
;;include=mdmcpq.inf
AddService=usbser, 0x00000002, DriverService


;;[MCB2300USB.nt.HW]
;;include=mdmcpq.inf
;;AddReg=LowerFilterAddReg

[DriverService]
DisplayName=%DRIVER.SVC%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\usbser.sys


;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------

[Strings]
Keil       ="Keil - An ARM Company"
DRIVER.SVC ="MCB2300 USB VCom Driver"
DESCRIPTION="MCB2300 USB VCom Port"
COMPOSITE ="MCB2300 CDC-CDC COM Port"

As may be obvious or not from the code written, I'm no pro at programming, however I fail to understand why the device would hang.
If requested I am able to send the whole Program, or provide more information as to what is the goal of this program or whatever information is needed

Hope someone can and is willing to help me with this problem

With kind regards
Tonino Reinbergen