Duplicate data received in all opened ports
Closed this issue · 4 comments
Thanks for the useful library.
We found an unexpected behaviour of the library in our implementation.
We forked your library and commit a few changes in order to make it work with our setup.
Hope this helps other users too.
Hardware setup
We have an Odroid M1 single board computer with 2 uart ports (uart0 and uart1) enabled on the DTB Overlay configuration.
In the uart pins of the GPIO slot we connected 2 ESP32 boards that periodically send different data.
Current behaviour
We opened both ports and added two separate data listeners:
import SerialPortAPI from 'react-native-serial-port-api';
const port0 = await SerialPortAPI.open('/dev/ttyS0', { baudRate: 115200 });
port0.onReceived((buffer: Buffer) => {
console.log('/dev/ttyS0', Array.from(buffer));
});
const port1 = await SerialPortAPI.open('/dev/ttyS1', { baudRate: 115200 });
port1.onReceived((buffer: Buffer) => {
console.log('/dev/ttyS1', Array.from(buffer));
});
The above code produces the following logs:
/dev/ttyS0 [51, 51, 51, 51, 52, 53, 54, 55, 56, 57] # actual data from S0 device
/dev/ttyS1 [51, 51, 51, 51, 52, 53, 54, 55, 56, 57] # data from S0 device, but received in S1
/dev/ttyS0 [48, 49, 50, 51, 52, 53, 54, 55, 56, 57] # data from S1 device, but received in S0
/dev/ttyS1 [48, 49, 50, 51, 52, 53, 54, 55, 56, 57] # actual data from S1 device
The above code and logs show that if we open 2 serial ports and both devices sends data, we receive duplicate data in both ports.
Proposed changes
We forked your library here @infobiotech/react-native-serial-port-api
Here is our commit infobiotech@df9bdb5
With the above changes, the code produces the following logs:
/dev/ttyS0 [51, 51, 51, 51, 52, 53, 54, 55, 56, 57] # actual data from S0 device
/dev/ttyS1 [48, 49, 50, 51, 52, 53, 54, 55, 56, 57] # actual data from S1 device
Right, it has this issue actually.
Hii @alessandroraffa, Could I get the repo link of your project?
Fixed in v1.4.0-rc.2
Hii @alessandroraffa, Could I get the repo link of your project?
Sorry @Ranjit8298, but it's a private repo for an internal project.