tidepool-org / pl2303

Prolific PL2303 user-space USB driver for Node.js
Other
4 stars 4 forks source link

Example with AT commands? #3

Open brandonros opened 4 years ago

brandonros commented 4 years ago
const device = new UsbSerial({
  baud: 115200
})
device.on('data', (data) => {
  console.log(data)
})
device.on('ready', () => {
  console.log('atz')
  device.send(Buffer.from('>ATZ\n'))
  setTimeout(() => {
    console.log('ati')
    device.send(Buffer.from('>ATI\n'))
  }, 5000)
})
$ node index.js 
atz
<Buffer 3e>
<Buffer 3f>
ati
<Buffer 3e>
<Buffer f2>

I would not expect this behavior. What am I doing wrong?

ironiridis commented 2 years ago

So the first response you're getting is >? so it sounds like the device you're talking to isn't expecting something. Based on the typical Hayes-style pattern for commands, I would expect you to send an ATZ\n at the start of the line. Of course, that depends entirely on the device you're communicating with at the other end of your USB-to-Serial device.