lpcware

LPC1347 - Virtual COM Port questions

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by BPC on Thu May 23 13:36:01 MST 2013
Hello All,

I am using the LPC1347 to read data from a 16 channel ADC and send the data over VCOM to a host PC application (i.e. PUTTY).  The buffer I am sending is 255 chars.  Currently, I simply call:
[COLOR=#3f7f5f][COLOR=#3f7f5f]

pUsbApi->[COLOR=#0000c0][COLOR=#0000c0]hw[/COLOR][/COLOR]->[COLOR=#0000c0][COLOR=#0000c0]WriteEP[/COLOR][/COLOR] (hUsb, USB_CDC_EP_BULK_IN, ([B][COLOR=#7f0055][COLOR=#7f0055]unsigned[/COLOR][/COLOR][/B][COLOR=#7f0055][COLOR=#7f0055][/COLOR][/COLOR] [B][COLOR=#7f0055][COLOR=#7f0055]char[/COLOR][/COLOR][/B][COLOR=#7f0055][COLOR=#7f0055][/COLOR][/COLOR] *)&outBuf[0], [B][COLOR=#642880][COLOR=#642880]strlen[/COLOR][/COLOR][/B][COLOR=#642880][COLOR=#642880][/COLOR][/COLOR](outBuf));
[COLOR=black]Everything works fine, but in reading some posts it seems like pUsbApi->hw->WriteEP should not be called directly.  Is this true?  As an experiment, I implemented the following: [/COLOR]

[B][COLOR=darkred][/COLOR][/B]
[B][COLOR=darkred]void[/COLOR] VCOM_usb_send[/B]([COLOR=#005032][COLOR=#005032]VCOM_DATA_T[/COLOR][/COLOR]* pVcom){
[COLOR=#3f7f5f][COLOR=#3f7f5f]//send txBuf of length [U]txlen[/U] over USB[/COLOR][/COLOR]
[COLOR=#3f7f5f][COLOR=#3f7f5f][/COLOR][/COLOR]pVcom->[COLOR=#0000c0][COLOR=#0000c0]txlen[/COLOR][/COLOR] -= pUsbApi->[COLOR=#0000c0][COLOR=#0000c0]hw[/COLOR][/COLOR]->[COLOR=#0000c0][COLOR=#0000c0]WriteEP[/COLOR][/COLOR] (pVcom->[COLOR=#0000c0][COLOR=#0000c0]hUsb[/COLOR][/COLOR], USB_CDC_EP_BULK_IN, pVcom->[COLOR=#0000c0][COLOR=#0000c0]txBuf[/COLOR][/COLOR], pVcom->[COLOR=#0000c0][COLOR=#0000c0]txlen[/COLOR][/COLOR]);
}

[COLOR=#005032][COLOR=#005032]VCOM_DATA_T[/COLOR][/COLOR]* pVcom = &g_vCOM;


pVcom->[COLOR=#0000c0][COLOR=#0000c0]txlen[/COLOR][/COLOR] = [B][COLOR=#642880][COLOR=#642880]strlen[/COLOR][/COLOR][/B][COLOR=#642880][COLOR=#642880][/COLOR][/COLOR](outBuf);pVcom->[COLOR=#0000c0][COLOR=#0000c0]txBuf[/COLOR][/COLOR] = ([COLOR=#005032][COLOR=#005032]uint8_t[/COLOR][/COLOR]*)outBuf;
pVcom->[COLOR=#0000c0][COLOR=#0000c0]send_fn[/COLOR][/COLOR](pVcom);

[COLOR=black]Both ways work well (as they are calling the same function in the end), but I would just like to know which is more "proper" or reliable.  Any input here would be greatly appreciated. Thank you.[/COLOR]
[/COLOR][/COLOR]

Outcomes