node-ftdi icon indicating copy to clipboard operation
node-ftdi copied to clipboard

Raspberry Pi 3 node app aborted

Open cesarGlz91 opened this issue 8 years ago • 2 comments

Hi! Im trying to interface a relay board interfaced by a ftdi chip. At this moment i can manage to install everything correctly, read the list of ftdi devices connected, open the device and write to it. After several writes to the device im getting this errors causing my node app to abort:

*** Error in `node': free(): invalid pointer: 0x6fc004ff *** Aborted

Also some times it outputs this:

*** Error in `node': munmap_chunk(): invalid pointer: 0x6fb0042b *** Aborted

I tried to run this app with both scenarios: node 8.4.0 with npm 5.3.0 and node 6.11.3 with npm 3.10.10 but still i get the same results.

Im using Raspbian Stretch image on my Raspberry Pi 3

This is my test application where i simply write a random byte to the 8 relay board each second:

const ftdi = require('ftdi');
const crypto = require('crypto');
let device;

const setRandomRelays = () => {
    const buffer = crypto.randomBytes(1);
    device.write(buffer, err => {
        if (err) console.log('FTDI Write Error: ' + err);
        else console.log('FTDI Write successful: ' + buffer.toString('hex'));
    });
    setTimeout(() => setRandomRelays(), 1000);
};

ftdi.find((err, devices) => {

    if (devices.length === 0) {
        console.log("No FTDI devices found");
    } else {

        device = new ftdi.FtdiDevice(devices[0]);
        console.log(device);

        device.on('error', e => {
            console.log('FTDI error ' + e);
        });

        device.open({
                baudrate: 921600,
                databits: 8,
                stopbits: 1,
                parity: 'none',
                bitmode: 'sync', // for bit bang
                bitmask: 0xff    // for bit bang
            },
            err => {

                if (err) {
                    console.log(err);
                    return;
                }

                device.on('data', data => {
                    console.log('FTDI on data: ' + data.toString('hex'));
                });

                setRandomRelays();

            });
    }
});

this is an output of the node app:

FtdiDevice {
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined,
  deviceSettings: 
   { description: 'FT245R USB FIFO',
     serialNumber: 'A700D6Y1',
     locationId: 262,
     index: 0,
     vendorId: 1027,
     productId: 24577 },
  FTDIDevice: FtdiDevice {} }
FTDI Write successful: 40
FTDI on data: 18
FTDI Write successful: 26
FTDI on data: 40
FTDI Write successful: f3
FTDI on data: 26
FTDI Write successful: b5
FTDI on data: f3
FTDI Write successful: bf
FTDI on data: b5
FTDI Write successful: 37
FTDI on data: bf
FTDI Write successful: 82
FTDI on data: 37
FTDI Write successful: 8e
FTDI on data: 82
FTDI Write successful: 6e
FTDI on data: 8e
FTDI Write successful: b5
FTDI on data: 6e
FTDI Write successful: b2
FTDI on data: b5
FTDI Write successful: ff
FTDI on data: b2
FTDI Write successful: 4b
FTDI on data: 00
*** Error in `node': free(): invalid pointer: 0x6fc004ff ***
Aborted

Maybe it has something to do with the node addon build and my version of node-gyp. Does someone know how to fix this?

cesarGlz91 avatar Sep 14 '17 18:09 cesarGlz91

Is there any update on this topic? I am having the same issue. I am sending characters from terminal that should be processed and printed on node.js. After a couple of characters the buffer is corrupted and I receive one of the the problems mentioned above.

Thanks and Br, // Tibor

twr7 avatar Nov 08 '18 15:11 twr7

Getting exactly the same issue. @cesarGlz91 did you manage to find a solution?

PID 14485 received SIGSEGV for address: 0x36312044 /noisemeter-collector/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x242c)[0x7638842c] /lib/arm-linux-gnueabihf/libc.so.6(__default_rt_sa_restorer_v2+0x0)[0x76c251a0]

wired8 avatar Oct 08 '20 03:10 wired8