Skip to content

Cannot read property 'open' of null #53

@juanstan

Description

@juanstan

This plugin is not working for me. It does not recognise the class as it returns null

"

import SerialPortAPI from 'react-native-serial-port-api';

async function example() {
/*  const devices = await SerialPortAPI.devicePathsAsync();
  console.log(devices)*/
  const serialPort = await SerialPortAPI.open("/dev/ttyS4", { baudRate: 38400 });
  console.log(serialPort, 'serialPort');

  // subscribe received data
  const sub = serialPort.onReceived(buff => {
    console.log(buff.toString('hex').toUpperCase());
  })

  // unsubscribe
  // sub.remove();

  // send data with hex format
  await serialPort.send('00FF');

  // close
  serialPort.close();

}

example();

"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions