cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual COM Port example: when communication is enabled?

Posted on June 30, 2009 at 11:05

Virtual COM Port example: when communication is enabled?

2 REPLIES 2
Posted on May 17, 2011 at 13:10

The Virtual COM Port example on the STM3210E board works well for me even with 2 Hyperterminals 🙂 or 1 Hyperterminal and RS-232C loopback.

I would like starting a transfer of data from the board to PC immediatelly after USB cable is plugged and Virtual COM port is opened by Hyperterminal (or by my test application in the future).

I thought that I can call a sending function after

while (bDeviceState != CONFIGURED);

but a string is probably tried to transfer too early.

When the function is called after recepted keystroke from Hyperterminal

i.e.

if ((count_out != 0) && (bDeviceState == CONFIGURED))

it works.

So any idea how to find that connection to host is running?

dimasusl
Associate II
Posted on May 17, 2011 at 13:10

This is not a very nice solution, but it works.

Modify your usb_prop.c file.

For one vcom:

Code:

u32 PortActive = 0;

void Virtual_Com_Port_Status_In(void)

{

if (Request == 0) {PortActive = 0;}

if (Request == SET_LINE_CODING)

{

PortActive = 1;

Request = 0;

}

}

For two vcom:

Code:

u8 DeviceIndex;

u8 Port0Active = 0;

u8 Port1Active = 0;

void Virtual_Com_Port_Status_In(void)

{

DEVICE_INFO *pInfo = &Device_Info;

//Defined by experience while debug application

DeviceIndex = pInfo->USBwIndexs.bw.bb0;

if (Request == 0)

{

if (DeviceIndex == 0) {Port0Active = 0;}

if (DeviceIndex == 1) {Port1Active = 0;}

}

if (Request == SET_LINE_CODING)

{

if (DeviceIndex == 0) {Port0Active = 1;}

if (DeviceIndex == 1) {Port1Active = 1;}

Request = 0;

}

}