Tag: 串口通讯

arduino和visual studio c ++,2路串行通信

我正在使用Arduino和Visual studio c ++并尝试构建双向实时串行通信。 我正在使用的是win 10(在VMware Fusion中),32位系统,visual studio 2013,Arduino IDE 1.8.0和Arduino板Uno。 我使用了http://playground.arduino.cc/Interfacing/CPPWindows中的库文件,它们是两个文件: SerialClass.h和Serial.cpp。 我在我的主要使用readData()和WriteData()函数。 我想再运行几次,用户可以在控制台中输入,Arduino会相应地生成输出。 但是当我添加while循环时,它无法正常工作。 下面是我的main.cpp :(在注释行中使用while循环) int main() { Serial* port = new Serial(“COM3”); if (port->IsConnected()) cout << "Connected!" << endl; char data[4] = ""; char command[2] = ""; int datalength = 4; //length of the data, int readResult = 0; int n; […]