在使用Readfile()读取串行端口时需要帮助 [英] need help on reading serial port using Readfile()

查看:184
本文介绍了在使用Readfile()读取串行端口时需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用Windows API读取串行端口数据,但不知何故我无法正确读取串行端口..有人可以请帮忙.谢谢

这是我读取串口的代码

i was trying to read a serial port data by using windows api but somehow i could not able to read the serial port properly.. would anyone kindly please help. thanks

this is my code for the reading of the serial port

//***************Read Operation******************//
buffRead = 0;
dwBytesRead = 0;
int nread =20;

if (!ReadFile(hSerial, buffRead, nread, &dwBytesRead, NULL))
{
printf("error reading from input buffer \n");
}
printf("Data read from read buffer is \n %s \n",buffRead);



谢谢

kevin



thanks

kevin

推荐答案

一个非常明显的错误是您将NULL 作为您的 lpBuffer 参数传递.
One very obvious error there is that you are passing NULL as your lpBuffer argument.


这篇关于在使用Readfile()读取串行端口时需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆