当前位置: 首页 > news >正文

北京市住房建设投资建设网站做商城网站要哪些流程

北京市住房建设投资建设网站,做商城网站要哪些流程,凡科h5在线制作,wordpress the7教程作者#xff1a; Herman Ye Galbot Auromix 测试环境#xff1a; Ubuntu20.04 更新日期#xff1a; 2023/08/30 注1#xff1a; Auromix 是一个机器人爱好者开源组织。 注2#xff1a; 本文在更新日期经过测试#xff0c;确认有效。 笔者出于学习交流目的#xff0c; 给…作者 Herman Ye Galbot Auromix 测试环境 Ubuntu20.04 更新日期 2023/08/30 注1 Auromix 是一个机器人爱好者开源组织。 注2 本文在更新日期经过测试确认有效。 笔者出于学习交流目的 给出以下ModbusCRC16校验常用的四种函数以及完整示例代码 1.计算CRC 注意 此处在末尾进行了高低位交换可根据需求删减代码交换高低位顺序。 unsigned short calculateModbusCRC16(const vectoruint8_t data) {int length data.size();unsigned short CRC 0xFFFF; // initial valuefor (int i 0; i length; i) {CRC CRC ^ data[i]; // XOR byte into least sig. byte of crcfor (int j 0; j 8; j) {if (CRC 1) {CRC 1;CRC ^ 0xA001;} else {CRC 1;}}}unsigned short swappedCRC ((CRC 8) 0xFF) | ((CRC 0xFF) 8);return swappedCRC; }2.添加CRC校验位 注意 此处进行了高低位交换可根据需求删减代码交换高低位顺序。 void addModbusCRC16(vectoruint8_t data) {unsigned short crc calculateModbusCRC16(data);// Append CRC bytes to the data vectordata.push_back((crc 8) 0xFF); // MSBdata.push_back(crc 0xFF); // LSB}3.删除CRC校验位 void removeModbusCRC16(vectoruint8_t dataWithCRC) {int length dataWithCRC.size();// Error checkif (length 2) {cerr Invalid data length endl;return;}// Delete CRC at the enddataWithCRC.resize(length - 2); }4.比较CRC校验位 bool compareModbusCRC16(const vectoruint8_t dataWithCRC) {int length dataWithCRC.size();// Error checkif (length 2) {cerr Invalid data length endl;return false;}// Get data without CRCvectoruint8_t dataWithoutCRC(dataWithCRC.begin(), dataWithCRC.end() - 2);// Calculateunsigned short calculatedCRC calculateModbusCRC16(dataWithoutCRC);// Get original CRCunsigned short originalCRC (dataWithCRC[length - 2] 8) | dataWithCRC[length - 1];return originalCRC calculatedCRC; }5.完整示例代码 #include iostream #include vector #include iomanip using namespace std;unsigned short calculateModbusCRC16(const vectoruint8_t data) {int length data.size();unsigned short CRC 0xFFFF; // initial valuefor (int i 0; i length; i) {CRC CRC ^ data[i]; // XOR byte into least sig. byte of crcfor (int j 0; j 8; j) {if (CRC 1) {CRC 1;CRC ^ 0xA001;} else {CRC 1;}}}unsigned short swappedCRC ((CRC 8) 0xFF) | ((CRC 0xFF) 8);return swappedCRC; }void addModbusCRC16(vectoruint8_t data) {unsigned short crc calculateModbusCRC16(data);// Append CRC bytes to the data vectordata.push_back((crc 8) 0xFF); // MSBdata.push_back(crc 0xFF); // LSB}void removeModbusCRC16(vectoruint8_t dataWithCRC) {int length dataWithCRC.size();// Error checkif (length 2) {cerr Invalid data length endl;return;}// Delete CRC at the enddataWithCRC.resize(length - 2); }bool compareModbusCRC16(const vectoruint8_t dataWithCRC) {int length dataWithCRC.size();// Error checkif (length 2) {cerr Invalid data length endl;return false;}// Get data without CRCvectoruint8_t dataWithoutCRC(dataWithCRC.begin(), dataWithCRC.end() - 2);// Calculateunsigned short calculatedCRC calculateModbusCRC16(dataWithoutCRC);// Get original CRCunsigned short originalCRC (dataWithCRC[length - 2] 8) | dataWithCRC[length - 1];// Logcout ModbusCRC16 original: hex originalCRC endl;cout ModbusCRC16 calculated: hex calculatedCRC endl;return originalCRC calculatedCRC; }int main() {// Example data 1vectoruint8_t deviceData1 {0x01, 0x10, 0x00, 0x02, 0x00, 0x06, 0x0C, 0x41, 0x20,0x00, 0x00, 0x42, 0xC8, 0x00, 0x00, 0x42, 0x48, 0x00, 0x00,0x84, 0xC1}; // Example CRC: 0x84, 0xC1// Print original datacout Original data 1: ;for (uint8_t byte : deviceData1) {cout hex uppercase setw(2) setfill(0) (int)byte ;}cout endl;bool comparedResultcompareModbusCRC16(deviceData1);if (comparedResult)coutCompared result: TRUEendl;elsecoutCompared result: FALSEendl;// Example data 2coutendl;vectoruint8_t deviceData2 {0x01, 0x06, 0x00, 0x00, 0x01, 0x02, 0x02};// Example CRC: 0xDA, 0xC7cout Original data 2: ;for (uint8_t byte : deviceData2) {cout hex uppercase setw(2) setfill(0) (int)byte ;}cout endl;// Add CRC and print modified dataaddModbusCRC16(deviceData2);cout Add CRC to original data 2: ;for (uint8_t byte : deviceData2) {cout hex uppercase setw(2) setfill(0) (int)byte ;}cout endl;// Remove CRC from dataremoveModbusCRC16(deviceData2);cout Remove CRC from modified data 2: ;for (uint8_t byte : deviceData2) {cout hex uppercase setw(2) setfill(0) (int)byte ;}cout endl; return 0; }
http://www.w-s-a.com/news/164066/

相关文章:

  • seo网站改版杭州建设局官网
  • 物流网站建设策划书泰然建设网站
  • 百度做网站的费用采集发布wordpress
  • 网站运维公司有哪些防录屏网站怎么做
  • 昆明做网站seo的网站制作专业
  • 聊城制作手机网站公司wordpress 头条
  • 商城微网站模板一般电商网站做集群
  • winserver2008上用iis发布网站嵊州网站制作
  • 网站内页权重怎么查辽宁建设工程信息网怎么上传业绩
  • 丰都网站建设价格镇江网站制作费用
  • app手机网站建设黄网站建设定制开发服务
  • 百度网盘app下载徐州优化网站建设
  • 附近网站电脑培训班展台设计方案介绍
  • 河南便宜网站建设价格低上海高端室内设计
  • 保险网站有哪些平台wordpress会员vip购买扩展
  • 网站怎么做图片转换广州车陂网站建设公司
  • 下载flash网站网站设计书的结构
  • 水利建设公共服务平台网站放心网络营销定制
  • 设计网站过程wordpress+分页静态
  • 临海网站制作好了如何上线如果安装wordpress
  • 长沙 学校网站建设网站制作价格上海
  • 九江网站推广徽hyhyk1国家住房部和城乡建设部 网站首页
  • 阿克苏网站建设咨询动漫设计与制作属于什么大类
  • 网站编辑做多久可以升职wordpress版权修改
  • 网站开发维护成本计算国外外贸平台
  • 简单的招聘网站怎么做购物网站功能报价
  • 哪个网站做中高端衣服建设自己网站的流程
  • 网站建设概况做网站的是怎么赚钱的
  • 网站发布信息的基本流程现在都不用dw做网站了吗
  • 赣州热门网站深圳龙岗做网站的公司