IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 嵌入式 -> MODBUS 透传 -> 正文阅读

[嵌入式]MODBUS 透传

概述

编写一段在 MODBUS 透传设备上的 Master 代码。透传设备上是通过串口转485模块跟485设备通信。透传设备上主要是按照 MODBUS Master的角色,发起 Request 并等待485设备的Response。其实,就是简单的调用了串口写后,再调用串口读超时。

参考文档及代码

MODBUS Application Protocol 1 1 bhttps://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdfAbout - Embedded Experts (embedded-experts.at)https://www.embedded-experts.at/en/freemodbus/about/luoyun1989/freemodbushttps://gitee.com/luoyun1989/freemodbus.gitluoyun1989/STM32_HAL_FREEMODBUS_RTUhttps://gitee.com/luoyun1989/STM32_HAL_FREEMODBUS_RTU.gitluoyun1989/FreeModbus_Slave-Master-RTT-STM32https://gitee.com/luoyun1989/FreeModbus_Slave-Master-RTT-STM32.gitluoyun1989/libmodbushttps://gitee.com/luoyun1989/libmodbus.git

代码编写

根据自己的串口驱动,实现write_ex,?read_ex,?read_ex中设置了500ms超时。(Master等待Slaver 回复的时间,通常设置为300~500ms,根据不同设备也可能是几秒)。

int32_t write_ex(uint8_t *buf, uint32_t buf_len) {

? ? uint32_t write_len = 0;

? ? int32_t retVal = rs232_write(s_pst232port, buf, buf_len, &write_len);

? ? return retVal;

}

int32_t read_ex(uint8_t *buf, uint32_t buf_len) {

? ? uint32_t read_len = 0;

? ? int32_t retVal = 0;

? ? if ((buf == NULL) || (buf_len < MAX_BUF_LEN)) {

? ? ? ? return -1;

? ? }

? ? retVal = rs232_read_timeout(s_pst232port, buf, buf_len, &read_len, 500);

? ? if (retVal == 0) {

? ? ? ? return read_len;

? ? }

? ? return -1;

}

#define MB_ADU_LEN ? ? ? ? ? ? ? ? ? ? ?256

#define MB_PDU_LEN ? ? ? ? ? ? ? ? ? ? ?(MB_ADU_LEN - 3)

#define MB_ADU_REQ_LEN_MIN ? ? ? ? ? ? ?8

#define MB_ADU_RSP_LEN_MIN ? ? ? ? ? ? ?5

#define MB_ADU_ADDR_INDEX ? ? ? ? ? ? ? 0

#define MB_ADU_FUNC_INDEX ? ? ? ? ? ? ? (MB_ADU_ADDR_INDEX + 1)

#define MB_ADU_START_ADDR_INDEX ? ? ? ? (MB_ADU_FUNC_INDEX + 1)

#define MB_ADU_QUANTITY_INDEX ? ? ? ? ? (MB_ADU_START_ADDR_INDEX + 2)

#define MB_ADU_COUNT_INDEX ? ? ? ? ? ? ?(MB_ADU_FUNC_INDEX + 1)

#define MB_ADU_INVALID_FUNC ? ? ? ? ? ? 0

#define MB_ADU_RSP_FUNC_EXCEPTION ? ? ? 0x80

#define MB_COILS_QUANTITY_MAX ? ? ? ? ? ? ? 2000 ?//0x7D0

#define MB_DISCRETE_INPUTS_QUANTITY_MAX ? ? 2000 ?//0x7D0

#define MB_INPUT_REGISTER_QUANTITY_MAX ? ? ?125 ?//0x7D

#define MAX_DATA_LEN ? ?48

typedef enum MB_function_code {? ?//常用的 Function Code,其它暂不实现

? ? MB_READ_COILS = 01,

? ? MB_READ_DISCRETE_INPUTS,

? ? MB_READ_HOLDING_REGISTERS,

? ? MB_READ_INPUT_REGISTER,

? ? MB_WRITE_SINGLE_COIL,

? ? MB_WRITE_SINGLE_REGISTER,

? ? MB_WRITE_MULTIPLE_COILS = 15,

? ? MB_WRITE_MULTIPLE_REGISTERS,

} tsModbusFunctionCode_t;

typedef struct MB_comm {

? ? uint8_t sendLen;? // request len

? ? uint8_t recvLen;? // expect response len

? ? uint8_t actRecvLen;? //actual response len

? ? uint8_t send[MAX_DATA_LEN];? // request buffer

? ? uint8_t recv[MAX_DATA_LEN];? // response buffer

} tsModbusComm_t;

tsModbusComm_t gModbusComm = {0};

uint16_t modbusCrc16(uint8_t *data, uint8_t dataLen) {

? ? uint8_t i, j;

? ? uint16_t crc = 0xFFFF;

? ? for (j = 0; j < dataLen; j++) {

? ? ? ? crc = crc ^ data[j];

? ? ? ? for (i = 0; i < 8; i++) {

? ? ? ? ? ? if ((crc & 0x0001) > 0) {

? ? ? ? ? ? ? ? crc = crc >> 1;

? ? ? ? ? ? ? ? crc = crc ^ 0xA001;

? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? crc = crc >> 1;

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ? return crc;

}

void modbusAddCrc16(uint8_t *data, uint8_t dataLen) {

? ? uint16_t crc16 = modbusCrc16(data, dataLen);

? ? data[dataLen] = LOW_BYTE(crc16);

? ? data[dataLen + 1] = HIGH_BYTE(crc16);

}

bool modbusCheckCrc16(uint8_t *data, uint8_t dataLen) {

? ? uint16_t crc16 = modbusCrc16(data, dataLen - 2);

? ? if (crc16 == HIGH_LOW_TO_INT(data[dataLen - 1], data[dataLen - 2])) {

? ? ? ? return true;

? ? }

? ? dbgWarning("CRC Error!!!");

? ? return false;

}

bool modbusCheckRequestAdu(void) {

? ? uint16_t quantity;

? ? tsModbusComm_t *pComm = &gModbusComm;

? ? uint8_t func = pComm->send[MB_ADU_FUNC_INDEX];

? ? if (!modbusCheckCrc16(pComm->send, pComm->sendLen)) {

? ? ? ? dbgWarning("crc error !\n");

? ? ? ? return false;

? ? }

? ? if (func == MB_ADU_INVALID_FUNC) {

? ? ? ? dbgWarning("invalid function code !\n");

? ? ? ? return false;

? ? }

? ? switch (func) {

? ? case MB_READ_COILS:

? ? case MB_READ_DISCRETE_INPUTS:

? ? ? ? if (pComm->sendLen == MB_ADU_REQ_LEN_MIN) { //addr(1), func(1), start addr(2), quantity(2), crc(2)

? ? ? ? ? ? quantity = HIGH_LOW_TO_INT(pComm->send[MB_ADU_QUANTITY_INDEX], pComm->send[MB_ADU_QUANTITY_INDEX + 1]);

? ? ? ? ? ? if (quantity <= MB_COILS_QUANTITY_MAX) {

? ? ? ? ? ? ? ? pComm->recvLen = MB_ADU_RSP_LEN_MIN; ? //addr(1), func(1), count(1), crc(2)

? ? ? ? ? ? ? ? pComm->recvLen += quantity / 8;

? ? ? ? ? ? ? ? pComm->recvLen += (quantity % 8) ? (1) : (0);

? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? break;

? ? case MB_READ_HOLDING_REGISTERS:

? ? case MB_READ_INPUT_REGISTER:

? ? ? ? if (pComm->sendLen == MB_ADU_REQ_LEN_MIN) { //addr(1), func(1), start addr(2), quantity(2), crc(2)

? ? ? ? ? ? quantity = HIGH_LOW_TO_INT(pComm->send[MB_ADU_QUANTITY_INDEX], pComm->send[MB_ADU_QUANTITY_INDEX + 1]);

? ? ? ? ? ? if (quantity <= MB_INPUT_REGISTER_QUANTITY_MAX) {

? ? ? ? ? ? ? ? pComm->recvLen = MB_ADU_RSP_LEN_MIN; ? //addr(1), func(1), count(1), crc(2)

? ? ? ? ? ? ? ? pComm->recvLen += quantity * 2;

? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? break;

? ? case MB_WRITE_SINGLE_COIL:

? ? case MB_WRITE_SINGLE_REGISTER:

? ? ? ? if (pComm->sendLen == MB_ADU_REQ_LEN_MIN) { //addr(1), func(1), start addr(2), value(2), crc(2)

? ? ? ? ? ? pComm->recvLen = pComm->sendLen;

? ? ? ? ? ? return true;

? ? ? ? }

? ? ? ? break;

? ? case MB_WRITE_MULTIPLE_COILS:

? ? case MB_WRITE_MULTIPLE_REGISTERS:

? ? ? ? if (pComm->sendLen >= MB_ADU_REQ_LEN_MIN) {

? ? ? ? ? ? pComm->recvLen = 8; //addr(1), func(1), start addr(2), quantity(2), crc(2)

? ? ? ? ? ? return true;

? ? ? ? }

? ? ? ? break;

? ? default:

? ? ? ? break;

? ? }

? ? return false;

}


?

bool modbusCheckResponseAduEx(void) {

? ? uint8_t count;

? ? tsModbusComm_t *pComm = &gModbusComm;

? ? uint8_t func = pComm->send[MB_ADU_FUNC_INDEX];

? ? switch (func) {

? ? case MB_READ_COILS:

? ? case MB_READ_DISCRETE_INPUTS:

? ? case MB_READ_HOLDING_REGISTERS:

? ? case MB_READ_INPUT_REGISTER:

? ? ? ? count = pComm->recv[MB_ADU_COUNT_INDEX];

? ? ? ? if ((pComm->actRecvLen == pComm->recvLen) &&

? ? ? ? ? ? ? ? (count == pComm->recvLen - 5)) {

? ? ? ? ? ? return true;

? ? ? ? }

? ? ? ? break;

? ? case MB_WRITE_SINGLE_COIL:

? ? case MB_WRITE_SINGLE_REGISTER:

? ? ? ? if (pComm->actRecvLen == pComm->recvLen) {

? ? ? ? ? ? if (memcmp(pComm->send, pComm->recv, pComm->actRecvLen) == 0) {

? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? break;

? ? case MB_WRITE_MULTIPLE_COILS:

? ? case MB_WRITE_MULTIPLE_REGISTERS:

? ? ? ? if (pComm->actRecvLen == pComm->recvLen) {

? ? ? ? ? ? if (memcmp(pComm->send, pComm->recv, 6) == 0) { //addr(1), func(1), start addr(2), quantity(2)

? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? }

? ? ? ? }

? ? ? ? break;

? ? default:

? ? ? ? return true;

? ? }

? ? return false;

}

bool modbusCheckResponseAdu(void) {

? ? uint8_t i;

? ? uint8_t tempLen;

? ? uint8_t temp[MAX_DATA_LEN] = {0};

? ? tsModbusComm_t *pComm = &gModbusComm;

? ? uint8_t len = pComm->actRecvLen;

? ? uint8_t *data = pComm->recv;

? ? for (i = 0; i < len; i++) {

? ? ? ? if ((data[i] == pComm->send[MB_ADU_ADDR_INDEX]) &&

? ? ? ? ? ? ? ? (data[i + 1] == pComm->send[MB_ADU_FUNC_INDEX])) {

? ? ? ? ? ? if (len - i < MB_ADU_RSP_LEN_MIN) {

? ? ? ? ? ? ? ? return false;

? ? ? ? ? ? }

? ? ? ? ? ? for (tempLen = len - i; tempLen >= MB_ADU_RSP_LEN_MIN; tempLen--) {

? ? ? ? ? ? ? ? if (modbusCheckCrc16(&data[i], tempLen)) {

? ? ? ? ? ? ? ? ? ? memcpy(temp, &data[i], tempLen);

? ? ? ? ? ? ? ? ? ? memcpy(data, temp, tempLen);

? ? ? ? ? ? ? ? ? ? pComm->actRecvLen = tempLen;

? ? ? ? ? ? ? ? ? ? return modbusCheckResponseAduEx();

? ? ? ? ? ? ? ? }

? ? ? ? ? ? }

? ? ? ? } else if ((data[i] == pComm->send[MB_ADU_ADDR_INDEX]) &&

? ? ? ? ? ? ? ? ? ?(data[i + 1] == pComm->send[MB_ADU_FUNC_INDEX] + MB_ADU_RSP_FUNC_EXCEPTION)) {

? ? ? ? ? ? if (len - i < MB_ADU_RSP_LEN_MIN) {

? ? ? ? ? ? ? ? return false;

? ? ? ? ? ? }

? ? ? ? ? ? tempLen = MB_ADU_RSP_LEN_MIN;

? ? ? ? ? ? if (modbusCheckCrc16(&data[i], tempLen)) {

? ? ? ? ? ? ? ? memcpy(temp, &data[i], tempLen);

? ? ? ? ? ? ? ? memcpy(data, temp, tempLen);

? ? ? ? ? ? ? ? pComm->actRecvLen = tempLen;

? ? ? ? ? ? ? ? dbgLog("MODBUS RESP EXCEPTION: 0x%02x\n", pComm->recv[MB_ADU_FUNC_INDEX]);

? ? ? ? ? ? ? ? return true;

? ? ? ? ? ? } else {

? ? ? ? ? ? ? ? return false;

? ? ? ? ? ? }

? ? ? ? }

? ? }

? ? return false;

}

void modbusRequestAndWaitResponse(void) {

? ? tsModbusComm_t *pComm = &gModbusComm;

? ? if (modbusCheckRequestAdu()) {

? ? ? ? dbgLog("send: \n");

? ? ? ? dbgPrintData(pComm->send, pComm->sendLen);

? ? ? ? write_ex((uint8_t *)pComm->send, (uint32_t)pComm->sendLen);

? ? ? ? pComm->actRecvLen = read_ex((uint8_t *)pComm->recv, MAX_DATA_LEN);

? ? ? ? if (pComm->actRecvLen != -1) {

? ? ? ? ? ? dbgLog("recv: \n");

? ? ? ? ? ? dbgPrintData(pComm->recv, pComm->actRecvLen);

? ? ? ? ? ? if (!modbusCheckResponseAdu()) {

? ? ? ? ? ? ? ? return;

? ? ? ? ? ? }

? ? ? ? ? ? dbgLog("recv_checked: \n");

? ? ? ? ? ? dbgPrintData(pComm->recv, pComm->actRecvLen);

? ? ? ? }

? ? }

}

#define MAX_SAMPLE_NUM ? 8

uint8_t gTestSamples[][MAX_DATA_LEN] = {? ?// 协议上的示例

? ? {0x08, 0x01, 0x01, 0x00, 0x13, 0x00, 0x13, 0x8C, 0x02}, ?//read coils request

? ? {0x08, 0x01, 0x01, 0x03, 0xCD, 0x6B, 0x05, 0x42, 0x82}, ?//read coils response

? ? {0x05, 0x01, 0x81, 0x01, 0x81, 0x90}, ?//read coils response exception

? ? {0x08, 0x01, 0x02, 0x00, 0xC4, 0x00, 0x16, 0xB8, 0x39}, ?//read discrete input request

? ? {0x08, 0x01, 0x02, 0x03, 0xAC, 0xDB, 0x35, 0x22, 0x88}, ?//read discrete input response

? ? {0x05, 0x01, 0x82, 0x01, 0x81, 0x60}, ?//read discrete input response exception

? ? {0x08, 0x01, 0x03, 0x00, 0x6B, 0x00, 0x03, 0x74, 0x17}, ?//read register request

? ? {0x0B, 0x01, 0x03, 0x06, 0x02, 0x2B, 0x00, 0x00, 0x00, 0x64, 0x05, 0x7A}, ?//read register response

? ? {0x05, 0x01, 0x83, 0x01, 0x80, 0xF0}, ?//read register response exception

? ? {0x08, 0x01, 0x04, 0x00, 0x08, 0x00, 0x01, 0xB0, 0x08}, ?//read input registers request

? ? {0x07, 0x01, 0x04, 0x02, 0x00, 0x0A, 0x39, 0x37}, ?//read input registers response

? ? {0x05, 0x01, 0x84, 0x01, 0x82, 0xC0}, ?//read input registers response exception

? ? {0x08, 0x01, 0x05, 0x00, 0xAC, 0xFF, 0x00, 0x4C, 0x1B}, ?//write single coil request

? ? {0x08, 0x01, 0x05, 0x00, 0xAC, 0xFF, 0x00, 0x4C, 0x1B}, ?//write single coil response

? ? {0x05, 0x01, 0x85, 0x01, 0x83, 0x50}, ?//write single coil response exception

? ? {0x08, 0x01, 0x06, 0x00, 0x01, 0x00, 0x03, 0x98, 0x0B}, ?//write single register request

? ? {0x08, 0x01, 0x06, 0x00, 0x01, 0x00, 0x03, 0x98, 0x0B}, ?//write single register response

? ? {0x05, 0x01, 0x86, 0x01, 0x83, 0xA0}, ?//write single register response exception

? ? {0x0B, 0x01, 0x0F, 0x00, 0x13, 0x00, 0x0A, 0x02, 0xCD, 0x01, 0x72, 0xCB}, ?//write multiple coil request

? ? {0x08, 0x01, 0x0F, 0x00, 0x13, 0x00, 0x0A, 0x24, 0x09}, ?//write multiple coil response

? ? {0x05, 0x01, 0x8F, 0x01, 0x85, 0xF0}, ?//write multiple coil response exception

? ? {0x0D, 0x01, 0x10, 0x00, 0x01, 0x00, 0x02, 0x04, 0x00, 0x0A, 0x01, 0x02, 0x92, 0x30}, ?//write multiple register request

? ? {0x08, 0x01, 0x10, 0x00, 0x01, 0x00, 0x02, 0x10, 0x08}, ?//write multiple register response

? ? {0x05, 0x01, 0x90, 0x01, 0x8D, 0xC0}, ?//write multiple register response exception

};

void modbusRequestAndWaitResponseSample(void) {? // 测试代码,调用前准备好 send, recv 数据

? ? tsModbusComm_t *pComm = &gModbusComm;

? ? if (modbusCheckRequestAdu()) {

? ? ? ? dbgLog("send: \n");

? ? ? ? dbgPrintData(pComm->send, pComm->sendLen);

? ? ? ? if (pComm->actRecvLen != -1) {

? ? ? ? ? ? dbgLog("recv: \n");

? ? ? ? ? ? dbgPrintData(pComm->recv, pComm->actRecvLen);

? ? ? ? ? ? if (!modbusCheckResponseAdu()) {

? ? ? ? ? ? ? ? return;

? ? ? ? ? ? }

? ? ? ? ? ? dbgLog("recv_checked: \n");

? ? ? ? ? ? dbgPrintData(pComm->recv, pComm->actRecvLen);

? ? ? ? }

? ? }

}

void modbusTest(void) {? //测试代码

? ? uint8_t i;

? ? tsModbusComm_t *pComm = &gModbusComm;

? ? dbgEnter();

? ? dbgLog("\r\n----------------------------------------\r\n");

? ? for (i = 0; i < 2; i++) {? ?//测试485 Request and response,需要连接 slaver

? ? ? ? pComm->sendLen = gTestSamples[5*3+1][0];

? ? ? ? memcpy(pComm->send, &gTestSamples[5*3+1][1], pComm->sendLen);

? ? ? ? modbusRequestAndWaitResponse();

? ? ? ? dbgLog("\r\n----------------------------------------\r\n");

? ? ? ? sleep(2);

? ? }

? ? for (i=0; i<MAX_SAMPLE_NUM; i++) // 测试sample,检测代码编写是否正确

? ? {

? ? ? ? memset(pComm, 0x00, sizeof(tsModbusComm_t));

? ? ? ? pComm->sendLen = gTestSamples[i*3][0];

? ? ? ? memcpy(pComm->send, &gTestSamples[i*3][1], pComm->sendLen);

? ? ? ? pComm->actRecvLen = gTestSamples[i*3+1][0];

? ? ? ? memcpy(pComm->recv, &gTestSamples[i*3+1][1], pComm->actRecvLen);

? ? ? ? modbusRequestAndWaitResponseSample();

? ? ? ? pComm->actRecvLen = gTestSamples[i*3+2][0];

? ? ? ? memcpy(pComm->recv, &gTestSamples[i*3+2][1], pComm->actRecvLen);

? ? ? ? modbusRequestAndWaitResponseSample();

? ? ? ? dbgLog("\r\n----------------------------------------\r\n");

? ? ? ? sleep(2);

? ? }

? ? dbgLeave();

}

// 测试485通信时,用 C# 做了一个串口工具,收到数据后自动回复同样的数据,可以初步测试?write single register request。

测试结果

Enter: mbxTestUart, 211
Enter: initUart, 162
LOG: initUart, 176:uart init ... OK!!!
LOG: initUart, 184:uart open (/dev/ttyS5) ... OK!!!
Leave: initUart, 193
Enter: modbusTest, 300
LOG: modbusTest, 301:
----------------------------------------
LOG: modbusRequestAndWaitResponse, 236:send:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponse, 241:recv:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponse, 246:recv_checked:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusTest, 306:
----------------------------------------
LOG: modbusRequestAndWaitResponse, 236:send:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponse, 241:recv:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponse, 246:recv_checked:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusTest, 306:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 01, 00, 13, 00, 13, 8c, 02,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 01, 03, cd, 6b, 05, 42, 82,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 01, 03, cd, 6b, 05, 42, 82,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 01, 00, 13, 00, 13, 8c, 02,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 81, 01, 81, 90,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x81
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 81, 01, 81, 90,
LOG: modbusTest, 320:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 02, 00, c4, 00, 16, b8, 39,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 02, 03, ac, db, 35, 22, 88,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 02, 03, ac, db, 35, 22, 88,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 02, 00, c4, 00, 16, b8, 39,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 82, 01, 81, 60,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x82
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 82, 01, 81, 60,
LOG: modbusTest, 320:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 03, 00, 6b, 00, 03, 74, 17,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 03, 06, 02, 2b, 00, 00, 00, 64, 05, 7a,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 03, 06, 02, 2b, 00, 00, 00, 64, 05, 7a,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 03, 00, 6b, 00, 03, 74, 17,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 83, 01, 80, f0,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x83
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 83, 01, 80, f0,
LOG: modbusTest, 320:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 04, 00, 08, 00, 01, b0, 08,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 04, 02, 00, 0a, 39, 37,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 04, 02, 00, 0a, 39, 37,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 04, 00, 08, 00, 01, b0, 08,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 84, 01, 82, c0,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x84
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 84, 01, 82, c0,
LOG: modbusTest, 320:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 05, 00, ac, ff, 00, 4c, 1b,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 05, 00, ac, ff, 00, 4c, 1b,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 05, 00, ac, ff, 00, 4c, 1b,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 05, 00, ac, ff, 00, 4c, 1b,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 85, 01, 83, 50,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x85
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 85, 01, 83, 50,
LOG: modbusTest, 320:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 06, 00, 01, 00, 03, 98, 0b,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 86, 01, 83, a0,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x86
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 86, 01, 83, a0,
LOG: modbusTest, 320:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 0f, 00, 13, 00, 0a, 02, cd, 01, 72, cb,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 0f, 00, 13, 00, 0a, 24, 09,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 0f, 00, 13, 00, 0a, 24, 09,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 0f, 00, 13, 00, 0a, 02, cd, 01, 72, cb,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 8f, 01, 85, f0,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x8f
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 8f, 01, 85, f0,
LOG: modbusTest, 320:
----------------------------------------
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 10, 00, 01, 00, 02, 04, 00, 0a, 01, 02, 92, 30,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 10, 00, 01, 00, 02, 10, 08,
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 10, 00, 01, 00, 02, 10, 08,
LOG: modbusRequestAndWaitResponseSample, 283:send:
01, 10, 00, 01, 00, 02, 04, 00, 0a, 01, 02, 92, 30,
LOG: modbusRequestAndWaitResponseSample, 286:recv:
01, 90, 01, 8d, c0,
LOG: modbusCheckResponseAdu, 223:MODBUS RESP EXCEPTION: 0x90
LOG: modbusRequestAndWaitResponseSample, 291:recv_checked:
01, 90, 01, 8d, c0,
LOG: modbusTest, 320:
----------------------------------------
Leave: modbusTest, 323
Leave: mbxTestUart, 215

  嵌入式 最新文章
基于高精度单片机开发红外测温仪方案
89C51单片机与DAC0832
基于51单片机宠物自动投料喂食器控制系统仿
《痞子衡嵌入式半月刊》 第 68 期
多思计组实验实验七 简单模型机实验
CSC7720
启明智显分享| ESP32学习笔记参考--PWM(脉冲
STM32初探
STM32 总结
【STM32】CubeMX例程四---定时器中断(附工
上一篇文章           查看所有文章
加:2021-11-17 12:54:59  更:2021-11-17 12:57:36 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/26 8:27:40-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码