industrialNETworXnetx

KJD

KJD

| 28.01.2009 | 11:13 | 5 replies

USB Byte Communication does not work properly

Hi,

I try to establish a communication between PC and NXHX-500 RE via USB.
I am using the CDC example and USB Windows driver are installed.
The standard example to get a byte and send it back works fine ("First test case. Normal loopback test with case invert").

But I want to build a ASCII parser to get hole commands and send acknowledge back, like a RS-232C commando parser.
The small CDC example was modified to this:

...
while(1)
{
bVal = usb_cdc_buf_rec_get();
if( 'A' == bVal )
{
usb_cdc_buf_send_put( 'B' );
usb_cdc_buf_send_flush();
}
}

With Hyperterminal I can send the letter 'A'. The development board was responding with 'B'.
This works fine. If I send a differnet letter - nothing happens, this is OK.
Afterwards typing the right letter again ('A'), the board doesn't respond!
Nothing happenes, it seems frozen.

What can I do? Should I clear the input buffer after got a byte, but how?

Thanks, KJD.

Chris Frickel

Chris Frickel

Hilscher

| 03.02.2009 | 14:48

Hi KJD,

Quote:
With Hyperterminal I can send the letter 'A'. The development board was responding with 'B'.
This works fine. If I send a differnet letter - nothing happens, this is OK.
Afterwards typing the right letter again ('A'), the board doesn't respond!
Nothing happenes, it seems frozen.

I just copied your code snipplet into the usb cdc demo and tried it with hyperterm. Everything worked fine. I typed "ABCDEFA" and get "BB" as response.

Have you tried to update the "usbser.sys" driver? The latest version is 5.1.2600.2180 .
Are you running the elf file from the HiTop Debugger or have you flashed the image?

micha1975er

micha1975er

| 11.02.2009 | 14:21

Hi,

I work with KJD already at the same projekt.

The code is running with the HITOP-Debugger.
Where can I get the latest usbser.sys file?

Thanks.

Andreas Jacob

Andreas Jacob

Hilscher Gesellschaft fuer Systemautomation mbH

| 16.02.2009 | 09:27

Hi micha1975er,

unfortunately it is not so easy to find the usbser.sys file. It is not delivered with the last Service Pack :cry:
The best way to update your version is to download the latest Bootwizard application from the Hilscher web page. There you will always find the latest and tested version.

micha1975er

micha1975er

| 23.02.2009 | 17:35

Hi,

Thank you for help.

In the downloaded Bootwizard application (Revision 1.0.398.0 / 05.01.2009) there was no usbser.sys file located.
Does the installation procedure install the new driver automatically? I don't know.

But anyway, there is a new problem with the CDC example.
After starting the original (unmodificated) CDC example, the program will not leave following while loop function:

while( usb_pollConnection()==USB_CDC_ConnectionState_Idle ) {};

The program is always running within this while loop function although the usb cable is connected to PC properly (virtual COM port was displayed in device manager when plugging to netX board).

What's happend?

Best regards
micha1975er

micha1975er

micha1975er

| 24.02.2009 | 17:39

Hi,

the function "while( usb_pollConnection()==USB_CDC_ConnectionState_Idle ) {};" will be successfully finished if a connection to a program is established. For example to start Hyperterminal with the right virtual COM port.

Whether a new usbser.sys driver was needed, I don't know.
My CDC example will work with following additional contents ('else' part):

while(1)
{
bVal = usb_cdc_buf_rec_get();
if( 'A' == bVal )
{
usb_cdc_buf_send_put( 'B' );
usb_cdc_buf_send_flush();
}
else
{
usb_cdc_buf_send_put( 0 );
usb_cdc_buf_send_flush();
}
}

Regards
micha1975er

Login