How can I split buffer where received the specific byte

Have you told us which version of the serial node you are using? You can see this from the Manage Palette menu in the editor.

Hi Colin, sorry I forgot to share it.
Would you see below my node-red version is 0.19.4, as you can see below:

Best Regards,
Alex

That does not tell us the version of serial port, at least not directly. Scroll down and you should see node-red-node-serialport

Hi Colin, would you see below my serial version:

Thanks a lot for your support!

Best Regards,
Alex

Well that is the latest version.
@dceejay is it possible that there is an error in the serialport node that causes repeated buffers when splitting on a character? I know 'possible' isn't the best word there because it is certainly possible. 'Likely' doesn't sound like a good word either, but you know what I mean.
I haven't got any serial hardware so I can't try and replicate it myself.
I had a quick look at the code but didn't see anything obvious, which isn't surprising.

Hi Guys!
I changed the serial USB dongle, change from PL203 to CP2102, to check if i´ll see any changes about duplication message, but still the same behavior!

Best Regards,
Alex

Hi - most odd... can you do us a favour and try something to help us debug this ?

Find the file 25-serial.js (probably under ~/.node-red/node_modules/node-red-node-serialport directory but depend of OS etc

in there find line 82 and insert a console.out line below like this

this.port.on('data', function(msgout) {
    console.log(typeof msgout, msgout.length, JSON.stringify(msgout));
    node.send(msgout);
});

Then restart Node-RED and watch the console to see what gets printed...
does the length match what you expect... Does it get printed twice per one input sent ?

Hi dceejay,
I found file 25-serial.js under /usr/lib/node_modules/node-red-node -serialport/

I have a doubt if I can change this file, under directory above, as you advise me. Please let me know if i can do it?

pi@raspberrypi:/usr/lib/node_modules/node-red-node-serialport $ ls -lt
total 60

Blockquote
drwxr-xr-x 153 root root 4096 Nov 2 21:20 node_modules
drwxr-xr-x 4 root root 4096 Nov 2 21:20 locales
-rw-r--r-- 1 root root 1462 Sep 17 19:18 package.json
-rw-r--r-- 1 root root 17422 Oct 26 1985 25-serial.html
-rw-r--r-- 1 root root 19957 Oct 26 1985 25-serial.js
-rw-r--r-- 1 root root 632 Oct 26 1985 LICENSE
-rw-r--r-- 1 root root 1751 Oct 26 1985 README.md
pi@raspberrypi:/usr/lib/node_modules/node-red-node-serialport $

Blockquote

Best Regards,
Alex

Yes sure. You will need to use sudo or root to access the file but yes, that is the one.

Hi dceejay,
I already yet include the new line that you advise me on 25-serial.js and I still received twice messages, as you can see below in the palette debug log 2x 19 (149) length and 2 x 18 (164) length messages.

To explain you better: my node send 1 message and wait to receive 2 messages.
Get Version (example that i should be receive)
07:50:56.612 -> 01 02 10 10 02 10 02 10 10 03
07:50:56.694 <- 01 80 00 00 05 95 00 00 00 10 00 03
07:50:56.874 <- 01 80 10 00 05 A4 00 01 00 30 00 03
You can see bellow, the pi log and palette debug information w/ rbe node:

Blockquote
26 Nov 10:12:50 - [info] serial port /dev/ttyUSB0 opened at 115200 baud 8N1
object undefined {"payload":{"type":"Buffer","data":[1,128,2,16,2,16,2,21,241,2,16,61,2,16,73,2,16,3]},"port":"/dev/ttyUSB0"}
object undefined {"payload":{"type":"Buffer","data":[1,128,2,16,2,16,2,21,242,2,16,62,2,16,73,2,16,3]},"port":"/dev/ttyUSB0"}
26 Nov 10:12:50 - [info] [debug:43313881.a42ee8]
<Buffer 01 80 02 10 02 10 02 15 f2 02 10 3e 02 10 49 02 10 03>
object undefined {"payload":{"type":"Buffer","data":[1,128,73,2,16,2,19,100,61,2,16,147,3]},"port":"/dev/ttyUSB0"}
26 Nov 10:12:50 - [info] [debug:43313881.a42ee8]
<Buffer 01 80 49 02 10 02 13 64 3d 02 10 93 03>
object undefined {"payload":{"type":"Buffer","data":[1,128,73,2,16,2,19,100,62,2,16,144,3]},"port":"/dev/ttyUSB0"}
26 Nov 10:12:50 - [info] [debug:43313881.a42ee8]
<Buffer 01 80 49 02 10 02 13 64 3e 02 10 90 03>
26 Nov 10:13:52 - [info] Stopping modified nodes
26 Nov 10:13:52 - [info] Stopped modified nodes
26 Nov 10:13:52 - [info] Starting modified nodes
26 Nov 10:13:52 - [info] Started modified nodes
object undefined {"payload":{"type":"Buffer","data":[1,128,2,16,2,16,2,21,149,2,16,2,16,2,16,16,2,16,3]},"port":"/dev/ttyUSB0"}
26 Nov 10:14:20 - [info] [debug:43313881.a42ee8]
<Buffer 01 80 02 10 02 10 02 15 95 02 10 02 10 02 10 10 02 10 03>
object undefined {"payload":{"type":"Buffer","data":[1,128,16,2,16,2,21,164,2,16,2,17,2,16,48,2,16,3]},"port":"/dev/ttyUSB0"}
26 Nov 10:14:20 - [info] [debug:43313881.a42ee8]
<Buffer 01 80 10 02 10 02 15 a4 02 10 02 11 02 10 30 02 10 03>
object undefined {"payload":{"type":"Buffer","data":[1,128,2,16,2,16,2,21,149,2,16,2,16,2,16,16,2,16,3]},"port":"/dev/ttyUSB0"}
26 Nov 10:14:20 - [info] [debug:43313881.a42ee8]
<Buffer 01 80 02 10 02 10 02 15 95 02 10 02 10 02 10 10 02 10 03>
object undefined {"payload":{"type":"Buffer","data":[1,128,16,2,16,2,21,164,2,16,2,17,2,16,48,2,16,3]},"port":"/dev/ttyUSB0"}
26 Nov 10:14:20 - [info] [debug:43313881.a42ee8]
<Buffer 01 80 10 02 10 02 15 a4 02 10 02 11 02 10 30 02 10 03>

Blockquote

try this...
Sorry for my poor english but

        0x16, 22d same your Start (0x01)

         0x17, 23d same your Stop (0x03)

        Example Tx:164f504e3030303017add7
        
	16 - Start
        
	4f - data
        
	....
        
	30 - data
        
	17 - Stop
        
	ad - crc16
        
	d7 - crc16

function RxCompleto( vetor,msg ) {

var pos = (vetor.length - 2) -1 // subtrai 1 por que vetor inicia em 0
            
msg.expr1 = (vetor[ pos] == 23)
            
msg.expr2 = ((vetor.length==1) && (vetor[0] == 21))
        
return ( (msg.expr1) || (msg.expr2) );

}

........

port.on('data', (data) => {

for ( var x = 0 ; x < data.length ; x++) {
				
	out.push( data[x])
			
}	
			
if (RxCompleto(out,msg)) {

      // Continue Your Code              
}

//Example
//Multiple Message
27 Nov 14:01:10 - [info] Log TxRxPinPad - Tx:164453503033322020415455414c495a414e444f20202020202020544142454c4153207c20202017d5b0/DSP032 ATUALIZANDO TABELAS | հ out:(42) md5:e193281c4cc9eb3349e5125d116112d7 003/027

27 Nov 14:01:10 - [info] Log TxRxPinPad - Tx:16544c523331363031333134313038303330374130303030303030303332303130303030303030303030303030303030303030303244454249544f202020202020202020203033303038433030384330303843303736393836323030303030303030303030303030303030303053595354454d202045304630453837303030463046303031323244383430303446383030303031303030303030304438343030304138303030303030303030303030303030303030303030303030303030303030303030303030303030303030304639463032303635463241303239413033394330313935303539463337303430303030303030303033394633373034303030303030303030303030303030303030303030303030303030303030303059315a3159335a334438343030344638303030303130303030303030443834303030413830301758b0/TLR316013141080307A000000003201000000000000000000002DEBITO 03008C008C008C07698620000000000000000000SYSTEM E0F0E87000F0F00122D84004F8000010000000D84000A80000000000000000000000000000000000000000000F9F02065F2A029A039C0195059F370400000000039F370400000000000000000000000000000000Y1Z1Y3Z3D84004F8000010000000D84000A800X� out:(326) md5:f0e145a35cd87d4c1ade6339af8da53a

27 Nov 14:01:11 - [info] Log TxRxPinPad. Rx:(22) cmd:[DSP] DSP000 ,TLR000 /DSP000 ,TLR000

27 Nov 14:01:11 - [info] Log TxRxPinPad. Rx:(22) cmd:[TLR] DSP000 ,TLR000 /DSP000 ,TLR000

@aargollo - the debug log out seems to look OK after you restart there are 4 messages

<Buffer 01 80 02 10 02 10 02 15 95 02 10 02 10 02 10 10 02 10 03>
<Buffer 01 80 10 02 10 02 15 a4 02 10 02 11 02 10 30 02 10 03>
<Buffer 01 80 02 10 02 10 02 15 95 02 10 02 10 02 10 10 02 10 03>
<Buffer 01 80 10 02 10 02 15 a4 02 10 02 11 02 10 30 02 10 03>

Yes they are repeated - but that looks like that is what is being received from the other end so I don't think there is a problem there.

One final thing to try - I see you are using deploy only modified nodes Stopping modified nodes - maybe try a complete redeploy as that stops and restarts everything.

@dceejay, I agree you its look like very stranger and i thing that also from the other side. But the unique thing that cause distrust is that when i used serialport without 0x03 as split byte is working very well. Don´t worrying I´ll try to implement a code sent by aco7432.

@aco7342, thanks a lot "Muito obrigado meu conterrâneo,pela ajuda".

I´ll let us know soon about the changes!
Best Regards,
Alex