Hardware-Handshake (RTS) do not work
Bernd-Wissler-KBR opened this issue · 0 comments
SerialPort Version
12.0.0
Node Version
v20.7.0
Electron Version
No response
Platform
Linux pkcm4test 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
=> Raspberry CM4
Architecture
ARM V8
Hardware or chipset of serialport
Raspberry CM4
What steps will reproduce the bug?
const { SerialPort } = require('serialport')
const port = new SerialPort({
path: '/dev/ttyAMA1',
baudRate: 38400,
autoOpen: true,
parity: 'even',
dataBits: 8,
stopBits: 1,
rtscts:true
})
port.open(function (err) {
if (err) {
return console.log('Error opening port: ', err.message)
}
console.log('Port opened! Starting timer')
setInterval(()=>{
console.log('Send HELLO')
port.write("HELLO",function(err){
if (err) {
return console.log('Error on write: ', err.message)
}
port.drain(function(){
console.log('- port data written')
})
});
},1000)
})
What happens?
The data is sent, but the RTS signal is not switched!
We tested it with an Oszilloscope!
The RTS signal could be switched back and forth with the manual command: port.set({rts:true/false}).
But we can't implement this with nodeJS because the timing would then become unacceptably bad
What should have happened?
I've already seen in the documentation that you probably haven't tested this board (V8) but it should probably work, but maybe you could still give me a tip on how to get it done.
Thank you and best regards to your Team
Additional information
With the following python script the RTS hardware handshake worked as desired!
import serial
import serial.rs485
import time
print("Test UART-Interface")
time.sleep(1)
print("Select Port: \n 0: /dev/ttyAMA0 \n 1: /dev/ttyAMA1 \n 2: /dev/ttyAMA2 \n 3: /dev/ttyAMA3 \n 4: /dev/ttyAMA4 \n 5: /dev/ttyAMA5")
iPortUserInput = int(input("Number: "))
if iPortUserInput == 0:
Port = "/dev/ttyAMA0"
elif iPortUserInput == 1:
Port = "/dev/ttyAMA1"
elif iPortUserInput == 2:
Port = "/dev/ttyAMA2"
elif iPortUserInput == 3:
Port = "/dev/ttyAMA3"
elif iPortUserInput == 4:
Port = "/dev/ttyAMA4"
elif iPortUserInput == 5:
Port = "/dev/ttyAMA5"
else:
quit()
# Open UART
uart = serial.Serial(
port=Port,
baudrate=38400,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_EVEN,
stopbits=serial.STOPBITS_ONE,
rtscts=True,
write_timeout=5,
timeout=1
)
uart.rs485_mode = serial.rs485.RS485Settings(
rts_level_for_tx=True,
rts_level_for_rx=False,
loopback=False,
delay_before_tx=0.0,
delay_before_rx=0.0
)
#
# Pint UART Status
print(uart)
time.sleep(3)
#
# Init Counter
iCounter = 0
#
# Test-data
a_byTxData = bytearray([1, 2, 5, 11, 22, 33, 44, 55, 99, 121, 122, 123, 128, 129, 190, 191, 192, 200, 205, 210, 215, 222, 234, 250, 254])
#
# 100 times send loop
while iCounter < 100:
iCounter = iCounter + 1
print(iCounter)
uart.write(a_byTxData)
# print status
print(uart.write)
time.sleep(1)
#
# Close
uart.close()
No response