Cape comms2의 Modbus RTU RS485를 Beaglebone black에서 작동하게 만드는 방법은 무엇입니까?

Cape comms2의 Modbus RTU RS485를 Beaglebone black에서 작동하게 만드는 방법은 무엇입니까?

저는 Cape comms2를 설정하고 데비안을 실행하면서 Modbus RTU RS 485를 Beaglebone Black에서 작동시키려고 며칠 동안 머리를 쥐어뜯었습니다.

/dev/ttyS0나는 다음과 같이 9600보드, 8비트 데이터, 1비트 정지, 패리티 없이 NodeJS 소프트웨어에 연결합니다.

            let SerialPort = require("serialport");
            let serialport = new SerialPort(this.device, { autoOpen: false, baudRate: 9600, stopbits: 1, databits: 8, parity: 'none' }, false);

            this.log('Opening serial connection… (client = ModbusRTU())')
            const client = new ModbusRTU(serialport)
            this.success('client is', client)
            this.log("Port Open Status: " + client.isOpen);
            client.open()

            // set a timout for requests default is null (no timeout)
            client.setTimeout(2e3)

            setInterval(() => {
                this.log("Port Open Status: " + client.isOpen);
                if (!client.isOpen) return

                run()

            },10e3)

            var i=0
            const run = () => {
                this.success(`Connected!`)

                this.success('--> Running…')
                if (i&1) read()
                else write()

                i++
                
                this.log('<-- Leaving run, but wait for the response in the future call back…')
            }

            /**
             * Read the RS485 packet: start adress 0x0C count 1 register
             */
            const read = () => {
                // read the 2 registers starting at address 5
                // on device number 1.
                this.log('About to read, setting the ID to 0xD2…')
                client.setID(0xD2)
                this.log('Now reading 1 register from start address 0x2A, wait for the response…')
                client
                //.readHoldingRegisters()
                .readHoldingRegisters(0x2A, 1)
                .then(args => this.log('Received SoC:', ...args))
                .catch(err => this.error('Received eror:', err))
                .finally(() => this.log('Received: finally'))

            }


            /**
             * Write to the RS485 register
             */
            const write = () => {
                // write the values 0, 0xffff to registers starting at address 5
                // on device number 1.
                //this.log('Writing: 0xD2, [0x03, 0x00, 0x0C, 0x00, 0x01, 0x57, 0xAA,]')
                this.log('Writing: FC3 0xD2,0x2A,1')
                client.setID(0xD2)
                if (true) {
                    client
                    .writeFC3(0x06,0x2A, 1, (err, data) => {
                        if (err) {
                            this.error('writeFC3:', err)
                        } else {
                            this.success('writeFC3:', data)
                        }
                    })
                }
            }

내가 얻은 로그는 다음과 같습니다.

Pepsr v2.2.236 9:56:14 AM 

관련 정보