1.下载开源的libplctag库
2.通过Cmake-gui生成工程文件
3.编译生成对应的Debug
4.配置VS studio
源码
#include "libplctag.h"
#include <cstring>
#include <iostream>
#include <thread>
int main() {
plc_tag_set_debug_level(PLCTAG_DEBUG_INFO); // 设置为INFO级别,避免过多日志
// 根据硬件信息调整参数(修正后)
const char* attrib_str =
"protocol=ab_eip&"
"gateway=172.16.2.51&"
"path=1,0&" // Slot 0 (CPU所在槽位)
"plc=ControlLogix&" // 必须是 "ControlLogix"(注意大小写)
"name=LMY20250617&" // PLC
// 名称或标签路径(若访问数组/结构体,需完整路径)
"ele