Exec node output - tostring() broken data

hello!

I do have a gps interface with a quite complex cmd output:

cgps -s -l s:

when I pout this in the exec node i get a buffer:
25.11.2021, 15:17:46node: f7486f94b9ec09bamsg : Object

object

payload: buffer[2055]raw

[0 … 9]

[10 … 19]

[20 … 29]

[30 … 39]

[40 … 49]

[50 … 59]

[60 … 69]

[70 … 79]

[80 … 89]

[90 … 99]

[100 … 109]

[110 … 119]

[120 … 129]

[130 … 139]

[140 … 149]

[150 … 159]

[160 … 169]

[170 … 179]

[180 … 189]

[190 … 199]

[200 … 209]

[210 … 219]

[220 … 229]

[230 … 239]

[240 … 249]

[250 … 259]

[260 … 269]

[270 … 279]

[280 … 289]

[290 … 299]

[300 … 309]

[310 … 319]

[320 … 329]

[330 … 339]

[340 … 349]

[350 … 359]

[360 … 369]

[370 … 379]

[380 … 389]

[390 … 399]

[400 … 409]

[410 … 419]

[420 … 429]

[430 … 439]

[440 … 449]

[450 … 459]

[460 … 469]

[470 … 479]

[480 … 489]

[490 … 499]

[500 … 509]

[510 … 519]

[520 … 529]

[530 … 539]

[540 … 549]

[550 … 559]

[560 … 569]

[570 … 579]

[580 … 589]

[590 … 599]

[600 … 609]

[610 … 619]

[620 … 629]

[630 … 639]

[640 … 649]

[650 … 659]

[660 … 669]

[670 … 679]

[680 … 689]

[690 … 699]

[700 … 709]

[710 … 719]

[720 … 729]

[730 … 739]

[740 … 749]

[750 … 759]

[760 … 769]

[770 … 779]

[780 … 789]

[790 … 799]

[800 … 809]

[810 … 819]

[820 … 829]

[830 … 839]

[840 … 849]

[850 … 859]

[860 … 869]

[870 … 879]

[880 … 889]

[890 … 899]

[900 … 909]

[910 … 919]

[920 … 929]

[930 … 939]

[940 … 949]

[950 … 959]

[960 … 969]

[970 … 979]

[980 … 989]

[990 … 999]

[1000 … 2055]

topic: ""

_msgid: "ec67773838452185"

when I convert that to string in a functio node with:

var b=Buffer.from(msg.payload);
var s=b.toString();
var out=s;
msg.payload= out;
return msg;

I get:
e[?1049he[22;0;0te[1;24re(Be[me[4le[?7he[He[2Je(0e[0mlqe[42bke(B
e(0e[0mxe(B Time:e[18Gn/ae[2;45He(0e[0mxe(B
e(0e[0mxe(B Latitude: n/ae[3;45He(0e[0mxe(B
e(0e[0mxe(B Longitude: n/ae[4;45He(0e[0mxe(B
e(0e[0mxe(B Altitude: n/ae[5;45He(0e[0mxe(B
e(0e[0mxe(B Speed:e[18Gn/ae[6;45He(0e[0mxe(B
e(0e[0mxe(B Heading: n/ae[7;45He(0e[0mxe(B
e(0e[0mxe(B Climb:e[18Gn/ae[8;45He(0e[0mxe(B
e(0e[0mxe(B Status: NO FIX (0 secs)e[9;45He(0e[0mxe(B
e(0e[0mxe(B Longitude Err: n/ae[10;45He(0e[0mxe(B
e(0e[0mxe(B Latitude Err: n/ae[11;45He(0e[0mxe(B
e(0e[0mxe(B Altitude Err: n/ae[12;45He(0e[0mxe(B
e(0e[0mxe(B Course Err:e[23Gn/ae[13;45He(0e[0mxe(B
e(0e[0mxe(B Speed Err:e[23Gn/ae[14;45He(0e[0mxe(B
e(0e[0mxe(B Time offset: n/ae[15;45He(0e[0mxe(B
e(0e[0mxe(B Grid Square: n/ae[16;45He(0e[0mxe(B
e(0e[0mmqe[42bje(Be[Ae(0e[0me(Be[1;46He(0e[0mlqe[32bke(Be[2;46He(0e[0mxe(BPRN: Elev: Azim: SNR: Used: e(0e[0mxe(Be[3;46He(0e[0mxe(B...

Ho can I fix this to get the right string?

Yes, that is annoying. Isn't there a parameter on the command to make it not output ansi codes? That's the problem you are getting and it would be better to avoid the problem rather than trying to post-fix it.

If you do need to fix, you will need to do some text replace. Look up the syntax for the JavaScript replace string function. Note that you will have to use the regular expression version of replace along with a regex global flag since you need to replace multiple entries.

Would you not be better off starting from a slightly more raw basic string interface like gpspipe

I don't think cgps is really intended for this.
Is this any use to you? node-red-contrib-gpsd (node) - Node-RED