How does node decode Linux device files after reading them to buffer?

  node.js, question

The requirement is to scan bar codes with a single chip computer and use it for subsequent network services.
However, there was a problem reading the barcode device file with node.

Linux was installed on the MCU
Cross-compile node
Connect barcode scanner to usb port of MCU
Every time the barcode is scanned successfully, the string will be output to the /dev/input/eventN file.
Try to read the file with node script to obtain scanned barcode data.

Node code

var fs = require('fs');
 
 var scannerFile = '/dev/input/event0';
 var readStream = fs.createReadStream(scannerFile);
 
 readStream.on('data', function (data) {
 var scannedText = data.toString('ascii');
 console.log(data);
 Log ('scannedText:' plus scannedtext');
 console.log('----------------------------');
 });

Run node script

# node ./scanner_watcher.js

“0123456789012” scanned.

Terminal Output Decoded in ASCII
ascii 解码的结果

The output decoded by utf-8 is also garbled
utf-8 解码的结果

Buffer data are as follows

<Buffer c8 36 71 57 51 3b 00 00 04 00 04 00 1e 00 07 00 c8 36 71 57 6f 3b 00 00 01 00 02 00 01 00 00 00 c8 36 71 57 6f 3b 00 00 00 00 00 00 00 00 00 00>
 <Buffer c8 36 71 57 fc 40 03 00 00 00 03 00 00 00 00 00 c8 36 71 57 fc 40 03 00 04 00 04 00 1f 00 07 00 c8 36 71 57 fc 40 03 00 01 00 03 00 01 00 00 00 c8 36 ... >

How to decode this Buffer object into correct barcode data?

The problem has been solved.

I forgot to enable the hid (human interface device) rawinput when configuring Linux Kernal.

After reconfiguring the compiled kernel, the barcode scanner is mapped to the /dev/hidraw-3 file.

After scanning, the file output ASCII code