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

USB CDC WorngPID error

Hi there! i've googling for a few days to find out what's wrong with my cdc implementation. Finally i found this forum with many threads about usb cdc.

I'm trying to connect my atmega3xx to my nokia s60 os through Max3421E. Nokia has a cdc class interface.

i initialize the device with some Setup Token. When i send a bulk-IN transfer to device it returns a NAK error which i believe it's normal because the device has no data to send.

When i tell the phone to send "Hello World" (J2me ,JSR 120, commConnection( USB:1)), the previous bulk-IN transfer i sent, starts to return WrongPID error.

My java aplicayion works fine with Hyperterminal through pc connection.

I'm getting crazy with this error. What can be causing this error?? is the Transfer baudRates?
Do i need to Send a Set_CodingLine according with what speed??

thanks in advanced!!

Parents
  • > sniff usb packets with snoopPro

    Is it done over a USB1.1 hub?
    When the phone is connected to a PC USB port directly, or over a USB2.0 hub, the phone exposes high-speed configuration. But when it is connected to MAX3421E, full-speed configuration appears. There is no guarantee that both configurations assign the same endpoints to the CDC interfaces.
    USB1.1 hub forces the bus speed to full speed. And then, you can see the full-speed configuration of the device on your PC.

    > Do i need to Send a Set_CodingLine according with what speed??

    I'm not sure.
    Following the CDC-ACM spec strictly, Set_Line_Coding request doesn't affect USB side at all. It sets up UART on the device, if any. But there are so many variation on the device implementations. Some device implementation may assign additional function to the request, apart from the original spec.

    It's better to examine the minimum requirement of the USB request on your PC.
    Make a simple PC application using Win32 serial API, which can communicate with the phone.
    And boil it down into minimum one.
    For example,

    
                                         // open the COM port - no request on the USB side
        HANDLE hCOM = CreateFile("\\\\.\\COM7", GENERIC_READ | GENERIC_WRITE, 0, 0,
                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    
                                        // set baudrate, parity, etc.
                                        // SetCommState() generates Get_Line_Coding, Set_Line_Coding
                                        // and Set_Control_Line_State requests
        DCB dcb;
        dcb.BaudRate = 115200;
        dcb.Parity   = NOPARITY;
        dcb.ByteSize = 8;
        dcb.StopBits = ONESTOPBIT;
        BOOL result = SetCommState( hCOM, &dcb );
    
                                        // assert DTR
                                        // EscapeCommFunction() puts Set_Control_Line_State
        EscapeCommFunction( hCOM, SETDTR );
    
                                        // send data to the device
                                        // WriteFile() generates bulk OUT transfer
        BYTE sampleData[16] = { 0x01, 0x02, ... };
        DWORD bytesWritten;
        WriteFile( hCOM, sampleData, 16, &bytesWritten, NULL );
    
                                        // read data from the device
                                        // ReadFile() puts no USB request, it reads RX buffer on the device driver
                                        // PC device driver repeats bulk IN transfer, separately, to fill the RX buffer
        DWORD bytesRead;
        ReadFile( hCOM, sampleData, 16, &bytesRead, NULL);
    
                                        // de-assert DTR
                                        // EscapeCommFunction() puts Set_Control_Line_State
        EscapeCommFunction( hCOM, CLRDTR );
    
                                        // CloseHandle() puts Set_Control_Line_State
        CloseHandle( hCOM );
    

    Does it still work without SetCommState() and/or EscapeCommFunction() ?
    When you get the minimum one, trace the USB request sequence on a sniffer
    And implement the sequence to MAX3421E

    Tsuneo

Reply
  • > sniff usb packets with snoopPro

    Is it done over a USB1.1 hub?
    When the phone is connected to a PC USB port directly, or over a USB2.0 hub, the phone exposes high-speed configuration. But when it is connected to MAX3421E, full-speed configuration appears. There is no guarantee that both configurations assign the same endpoints to the CDC interfaces.
    USB1.1 hub forces the bus speed to full speed. And then, you can see the full-speed configuration of the device on your PC.

    > Do i need to Send a Set_CodingLine according with what speed??

    I'm not sure.
    Following the CDC-ACM spec strictly, Set_Line_Coding request doesn't affect USB side at all. It sets up UART on the device, if any. But there are so many variation on the device implementations. Some device implementation may assign additional function to the request, apart from the original spec.

    It's better to examine the minimum requirement of the USB request on your PC.
    Make a simple PC application using Win32 serial API, which can communicate with the phone.
    And boil it down into minimum one.
    For example,

    
                                         // open the COM port - no request on the USB side
        HANDLE hCOM = CreateFile("\\\\.\\COM7", GENERIC_READ | GENERIC_WRITE, 0, 0,
                                 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
    
                                        // set baudrate, parity, etc.
                                        // SetCommState() generates Get_Line_Coding, Set_Line_Coding
                                        // and Set_Control_Line_State requests
        DCB dcb;
        dcb.BaudRate = 115200;
        dcb.Parity   = NOPARITY;
        dcb.ByteSize = 8;
        dcb.StopBits = ONESTOPBIT;
        BOOL result = SetCommState( hCOM, &dcb );
    
                                        // assert DTR
                                        // EscapeCommFunction() puts Set_Control_Line_State
        EscapeCommFunction( hCOM, SETDTR );
    
                                        // send data to the device
                                        // WriteFile() generates bulk OUT transfer
        BYTE sampleData[16] = { 0x01, 0x02, ... };
        DWORD bytesWritten;
        WriteFile( hCOM, sampleData, 16, &bytesWritten, NULL );
    
                                        // read data from the device
                                        // ReadFile() puts no USB request, it reads RX buffer on the device driver
                                        // PC device driver repeats bulk IN transfer, separately, to fill the RX buffer
        DWORD bytesRead;
        ReadFile( hCOM, sampleData, 16, &bytesRead, NULL);
    
                                        // de-assert DTR
                                        // EscapeCommFunction() puts Set_Control_Line_State
        EscapeCommFunction( hCOM, CLRDTR );
    
                                        // CloseHandle() puts Set_Control_Line_State
        CloseHandle( hCOM );
    

    Does it still work without SetCommState() and/or EscapeCommFunction() ?
    When you get the minimum one, trace the USB request sequence on a sniffer
    And implement the sequence to MAX3421E

    Tsuneo

Children
No data