【发布时间】:2012-08-29 15:19:12
【问题描述】:
我是 c++ 新手,我试图从 c++ 中的函数读取 COM 端口 以下是代码说明,有人可以帮我完成吗? 该函数应获取评论的值,请帮助我 谢谢你
int ComPortReading( short, wchar_t * Data[], wchar_t **Output, SIZE_T *OutputSize )
{
int result = 1;
if( Data[0] )
{
*OutputSize = 50;
*Output = (wchar_t *) CoTaskMemAlloc(*OutputSize);
if( *Output )
{
wchar_t *EndPtr;
double v11 = wcstod(Data[0], &EndPtr); // Port Name
double v12 = wcstod(Data[1], &EndPtr); // Baud Rate
double v13 = wcstod(Data[2], &EndPtr); // Data Bits
double v14 = wcstod(Data[3], &EndPtr); // Stop Bits
double v15 = wcstod(Data[4], &EndPtr); // Parity
// Need to write code here to read COM port
// Com port settings can be taken from the above v11 - v15 values
swprintf(*Output, L"%.10lf", v11);
result = 0;
}
}
return result;
}
【问题讨论】:
-
我没有看到任何实际从 COM 端口读取字节的代码,所以您实际上是在询问有关 C++ 字符串处理的问题。