Serial Port not working in custom Edge Driver on Tulip player

Dear Tulip Community,

This is my first time posting, so excuse me if I did something wrong. I am trying to connect an ESP32 with the Tulip player with a custom edge driver and send/read commands from the serial port. I am following this walkthrough SDK develop

When I tried to connect to the ESP via serial, I get the following issues. The driver itself registers and works fine as seen in the first lines in the console but fails to connect to the serial port.

I checked if the ESP’s serial port is not blocked, but it is open and I can send and receive commands from the terminal, so there is no issues on that side.

Any help is appreciated :slight_smile:

I use the following code in the driver:

 const serial = new edgeDriverSdk.SerialPort('COM6', { baudRate: 115200 });

serial.onData((data) => {
  try {
    const decoder = new TextDecoder();
    const stringData = decoder.decode(new Uint8Array(data));
    const espData = JSON.parse(stringData.split('ESP: ')[1]);
    edgeDriverSdk.fireEvent('status', espData);
  } catch (error) {
    console.error(error);
  }
});

serial.open().then(() => console.log('COM6 opened'))
    .catch((e) => console.error('Failed to open COM6:', e));

edgeDriverSdk.registerDriverFunction('led_on', async () => {
  await serial.send(JSON.stringify({ command: 'led_on' }) + '\n');
});

edgeDriverSdk.registerDriverFunction('led_off', async () => {
  await serial.send(JSON.stringify({ command: 'led_off' }) + '\n');
});

Additional errors from the console when I try to list the available ports

edgeDriverSdk.SerialPort.listAvailablePorts().then((ports) => {
  const esp32port = ports.find((port) => (port as any).productId === 29987);
  serial = new edgeDriverSdk.SerialPort(esp32port.path, {
    baudRate: 115200,
  });

Tulip developers responded that this is a listAvailablePorts does not work and it isknown issue in version 2.10.3 and will be fixed in 2.11. For now, manually set the COM port to the desired one. After manually setting the port, I believe I wrote the wrong port number and could not connect to my device. Make sure you find the port number in Device Manager. Good luck!