我正在编写代码以使用串行连接连接到仪器并发送一些命令.到目前为止,这是我的代码:
#include <boost/asio/basic_serial_port.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
#define PORT "COM3"
#define BAUD 9600
#define DATABITS 8
#define PARITY none
#define STOP_BITS one
#define FLOW_CONTROL none
int main()
{
using namespace boost;
//Create the serial connection to the scope
asio::io_service io;
asio::basic_serial_port<asio::serial_port_service> scope(io);
//Open the connection and configure it
scope.open(PORT);
scope.set_option(asio::serial_port_base::baud_rate(BAUD));
scope.set_option(asio::serial_port_base::flow_control(asio::serial_port_base::flow_control::FLOW_CONTROL));
scope.set_option(asio::serial_port_base::parity(asio::serial_port_base::parity::PARITY));
scope.set_option(asio::serial_port_base::stop_bits(asio::serial_port_base::stop_bits::STOP_BITS));
scope.set_option(asio::serial_port_base::character_size(DATABITS));
//Open the connection
//Send some test commands
scope.write_some("MOVE X Y \n");
//Close the port
scope.close();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它在visual studio中看起来很好但是在编译时给出了16个错误,所有这些都在boost的buffer_sequence_adapter.hpp中first.库代码当然看起来很好,所以我不确定为什么它不会编译.一些错误如下:
Error 1 …Run Code Online (Sandbox Code Playgroud)