npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

kds-modbus-simulator

v1.0.0

Published

A Node-RED node to simulate Modbus RTU protocol messages

Downloads

160

Readme

커스텀 노드 개발(모드버스 시뮬레이터 노드)

Modbus Simulator Node 명세서

1. 개요

Modbus Simulator Node는 Node-RED 환경에서 Modbus RTU 프로토콜 메시지를 시뮬레이션하기 위한 커스텀 노드입니다. 이 노드는 inject 노드와 유사한 방식으로 작동하며, 설정된 간격으로 Modbus RTU 형식의 메시지를 생성합니다.

2. 주요 기능

2.1 기본 기능
  • Modbus RTU 메시지 생성
  • inject 스타일의 실행 버튼
  • 주기적 메시지 생성 기능
  • CRC 자동 계산 및 추가
2.2 설정 가능한 파라미터
  1. Unit ID (슬레이브 주소)

    • 범위: 1-247
    • 기본값: 1
    • 설명: Modbus 슬레이브 장치의 식별자
  2. Function Code (기능 코드)

    • 지원 코드:
      • 0x03: Read Holding Registers
      • 0x04: Read Input Registers
      • 0x06: Write Single Register
      • 0x10: Write Multiple Registers
    • 기본값: 0x03 (Read Holding Registers)
  3. Start Address (시작 주소)

    • 범위: 0-65535
    • 기본값: 0
    • 설명: 레지스터 시작 주소
  4. Quantity (레지스터 개수)

    • 범위: 1-125 (Read 작업 시)
    • 기본값: 1
    • 설명: 읽거나 쓸 레지스터의 개수
  5. Interval (실행 간격)

    • 단위: 초
    • 기본값: 5초
    • 설명: 반복 실행 시 메시지 생성 간격

3. 출력 메시지 형식

3.1 기본 출력 구조
{
    payload: "01 03 0002 000A C5 CD", // Modbus RTU 메시지 (Hex 형식)
    timestamp: 1704861234567          // 메시지 생성 시간 (Unix timestamp)
}
3.2 Modbus RTU 메시지 구조
  1. Slave Address (1 byte)
  2. Function Code (1 byte)
  3. Data (N bytes)
  4. CRC (2 bytes)

4. 작동 모드

4.1 단일 실행 모드
  • 노드 좌측의 실행 버튼 클릭 시 한 번 실행
  • 입력 메시지 수신 시 한 번 실행
4.2 반복 실행 모드
  • Repeat 옵션 활성화 시 사용 가능
  • 설정된 간격으로 주기적 실행
  • 노드 비활성화 또는 플로우 중지 시 자동 중단

5. 오류 처리

  • 잘못된 파라미터 입력 시 기본값 사용
  • CRC 계산 실패 시 오류 메시지 출력
  • 통신 오류 발생 시 노드 상태 표시 변경

6. 사용 제한 및 주의사항

  • 최대 동시 실행 개수: 제한 없음
  • 최소 실행 간격: 1초
  • 메모리 사용량: 일반적인 Node-RED 노드 수준
  • 권장 Node-RED 버전: 2.0.0 이상

7. 구현 세부사항

7.1 CRC 계산 알고리즘
function calculateCRC(buffer) {
  let crc = 0xffff;
  for (let i = 0; i < buffer.length; i++) {
    crc ^= buffer[i];
    for (let j = 0; j < 8; j++) {
      if (crc & 0x0001) {
        crc >>= 1;
        crc ^= 0xa001;
      } else {
        crc >>= 1;
      }
    }
  }
  return crc & 0xffff;
}
7.2 메시지 생성 로직
  1. 기본 메시지 버퍼 생성 (6 bytes)
  2. 설정값 기반 데이터 입력
  3. CRC 계산 및 추가
  4. Hex 문자열로 변환

8. 확장 가능성

  1. 추가 Modbus 기능 코드 지원
  2. 다양한 데이터 타입 지원
  3. 응답 메시지 시뮬레이션 기능
  4. 에러 상황 시뮬레이션 기능
  5. 데이터 로깅 기능

9. 설치 및 배포

  1. 노드 설치: npm install kds-modbus-simulator
  2. 노드 업데이트: npm update kds-modbus-simulator
  3. 수동 설치: Node-RED 사용자 디렉토리에 파일 복사