新建项目
This commit is contained in:
1 parent
5e2e890cfc
commit
633d9b872b
1351 files changed
+730564
No files matched your search
@@ -0,0 +1,33 @@
|
||||
/* modbus 主机实现*/
|
||||
|
||||
#include<stdint.h>
|
||||
#include "crc.h"
|
||||
|
||||
|
||||
//static uint8_t s_tx_buffer[512];
|
||||
//static uint16_t s_tx_length;
|
||||
//static uint8_t rx_buffer[512];
|
||||
|
||||
|
||||
|
||||
// 读取保持寄存器的值
|
||||
// addr 寄存器地址
|
||||
// id 丛机地址
|
||||
// length 读取丛机数据长度
|
||||
int modbus_m_read_regist(uint8_t id,uint16_t addr,uint16_t length,uint8_t * data)
|
||||
{
|
||||
uint16_t index = 0,crc;
|
||||
data[index++] = id;
|
||||
data[index++] = 0x03;
|
||||
data[index++] = (addr >> 8) & 0x00FF;
|
||||
data[index++] = addr & 0x00FF;
|
||||
data[index++] = (length >> 8) & 0x00FF;
|
||||
data[index++] = length & 0x00FF;
|
||||
crc = MX_CRC_CALC(data,index);
|
||||
data[index++] = crc & 0x00FF;
|
||||
data[index++] = (crc >> 8) & 0x00FF;
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef MODBUS_M_H
|
||||
#define MODBUS_M_H
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
int modbus_m_read_regist(uint8_t id,uint16_t addr,uint16_t length,uint8_t * data);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
/* modbus 主机实现*/
|
||||
|
||||
#include<stdint.h>
|
||||
|
||||
|
||||
static uint8_t s_tx_buffer[512];
|
||||
static uint16_t s_tx_length;
|
||||
static uint8_t rx_buffer[512];
|
||||
|
||||
|
||||
|
||||
// 读取保持寄存器的值
|
||||
// addr 寄存器地址
|
||||
// id 丛机地址
|
||||
// length 读取丛机数据长度
|
||||
int modbus_m_read_regist(uint8_t id,uint16_t addr,uint16_t length)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user