Could someone please tell me the code needed to send out the ascii value of a CString class variable out port 1?
Printable View
Could someone please tell me the code needed to send out the ascii value of a CString class variable out port 1?
Include the MS Commnication control to your object.Create the control in one of
your classes. Use the memeber function for outputting the string to the any of the COM
port.
I am able to send a CString all right. But I want to send an array of BYTES :
unsigned char arr[100];
I am able to send this through the Com port using MSComm control. But at the receiving end, I am stuck. The incoming array is available wrapped inside a VARIANT. How to extract my array from within this variant ? Should I use a SafeArray ?
I'm not sure how to convert the variant to SafeArray.
Please help me with a piece of code, if possible.
Thanks.
nikku
nikku
The return type is a VARIANT. The vt field (VARTYPE) should be equal to 0x2011 and the parray field data is a pointer to a SAFEARRAY that contains the data.
To find out how many bytes have been received from the port you could do the following:
VARIANT varg;
varg = MSCommObj.GetOutput();
if(varg.vt != 0x2011) // don't know if this absolutely correct!!!
continue;
number of bytes read from COM1 = varg.parray->rgsabound[0].cElements
ptr to array of bytes read = varg.parray->pvData
Kevin M. Reilly