当前位置: 首页> 健康> 美食 > abc是什么平台_郑州网站建设公司怎么选_嘉兴seo外包公司_steam交易链接在哪复制

abc是什么平台_郑州网站建设公司怎么选_嘉兴seo外包公司_steam交易链接在哪复制

时间:2025/7/12 19:46:14来源:https://blog.csdn.net/qq_49595983/article/details/144677634 浏览次数:0次
abc是什么平台_郑州网站建设公司怎么选_嘉兴seo外包公司_steam交易链接在哪复制
  1. Vs2022选择配置属性选择高级语言运行时(/clr);
  2. 符合模式选择否;
  3. 引用选择Hslcommunication.dll和HslCppExtension.dll;
    Demo
#include <iostream>
using namespace HslCommunication;
using namespace HslCommunication::Core::Net;
using namespace HslCommunication::ModBus;
int main()
{std::cout << "Hello World!\n";System::String^ ipAddress = gcnew System::String("127.0.0.1");ModbusTcpNet^ modbus = gcnew ModbusTcpNet(ipAddress, 502, 1);modbus->DataFormat = HslCommunication::Core::DataFormat::CDAB;OperateResult^ connect = modbus->ConnectServer();if (connect->IsSuccess) {printf("Connect modbus success\n");}else{printf("Connect failed:");printf((char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(connect->Message));printf("\n");return 0;}System::String^ dataAddress = gcnew System::String("100");OperateResult<short>^ readValue = modbus->ReadInt16(dataAddress);if (readValue->IsSuccess) {short value = readValue->Content;printf("Read[100] Value:%d \n", value);}else{printf("Read Failed: ");printf((char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(readValue->Message));printf("\n");return 0;}modbus->ConnectClose();
}
关键字:abc是什么平台_郑州网站建设公司怎么选_嘉兴seo外包公司_steam交易链接在哪复制

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: